摘要: #include <stdlib.h>#include <stdio.h>#include <string.h>int main(int argc,char **argv){ char *var,*value; if(argc==1||argc>3) { exit(1); } var=argv[1]; value=getenv(var); if(value) printf("Variable %s has value %s\n",var,... 阅读全文
posted @ 2012-09-08 10:46 Dsp Tian 阅读(618) 评论(0) 推荐(0)
摘要: #include <stdio.h>#include <unistd.h>int main(int argc,char **argv){ int opt; while((opt=getopt(argc,argv,"if:lr"))!=-1) { switch(opt) { case 'i': case 'l': case 'r': ... 阅读全文
posted @ 2012-09-08 10:22 Dsp Tian 阅读(477) 评论(0) 推荐(0)
摘要: #include <stdio.h>#include <stdlib.h>extern char **environ;int main(){ char **env=environ; while(*env) { printf("%s\n",*env); env++; } exit(0);}主要是environ变量,定义如下#include <stdlib>extern char **environ; 阅读全文
posted @ 2012-09-08 09:59 Dsp Tian 阅读(483) 评论(0) 推荐(0)