上一页 1 ··· 59 60 61 62 63 64 65 66 67 ··· 79 下一页
摘要: #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 阅读(619) 评论(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)
摘要: #include <stdio.h>#include <stdlib.h>int main(){ int c; FILE *in,*out; in=fopen("file.in","r"); out=fopen("file.out","w"); while((c=fgetc(in))!=EOF) fputc(c,out); exit(0);} 阅读全文
posted @ 2012-09-06 14:13 Dsp Tian 阅读(2021) 评论(0) 推荐(0)
摘要: #include <unistd.h>#include <fcntl.h>#include <sys/types.h>#include <sys/stat.h>#include <stdlib.h>int main(){ char block[1024]; int in,out; int nread; in=open("file.in",O_RDONLY); out=open("file.out",O_WRONLY|O_CREAT,S_IRUSR|S_IWUSR); while ((nread= 阅读全文
posted @ 2012-09-06 14:12 Dsp Tian 阅读(725) 评论(0) 推荐(0)
摘要: #include <unistd.h>#include <stdlib.h>int main(){ char buffer[128]; int nread; nread=read(0,buffer,128); if(nread==-1) write(2,"A read error has occurred\n",26); if((write(1,buffer,nread))!=nread) write(2,"A write error has occurred\n"... 阅读全文
posted @ 2012-09-02 17:43 Dsp Tian 阅读(647) 评论(0) 推荐(0)
摘要: #include <unistd.h>#include <stdlib.h>int main(){ if((write(1,"here is some data\n",18))!=18) write(2,"write error\n",12); exit(0);}原型:#include <unistd.h>size_t write(int fildes,const void *buf,size_t nbytes);write()的第一个参数:0标准输入,1标准输出,2标准错误 第二个参数:写入的数据 第三个参数:写入如 阅读全文
posted @ 2012-09-02 16:46 Dsp Tian 阅读(1549) 评论(0) 推荐(0)
摘要: 偶然在http://forum.ubuntu.org.cn上看到一个帖子中有一个随机变化的linux技巧表,就将其js脚本搞了出来,代码中写的技巧都挺有用的。tips = new Array(222);code = new Array(222);tips[0] = '查看软件xxx安装内容';code[0] = 'dpkg -L xxx';tips[1] = '查找软件库中的软件';code[1] = 'apt-cache search 正则表达式';tips[2] = '查找软件库中的软件';code[2] = 阅读全文
posted @ 2012-08-10 15:53 Dsp Tian 阅读(1146) 评论(0) 推荐(0)
摘要: #include <iostream> #include <string> #include <set> using namespace std; int main() { string name[]={"tian","dsp","sp","ti"}; set<string> setname; fo 阅读全文
posted @ 2012-07-26 16:23 Dsp Tian 阅读(802) 评论(0) 推荐(0)
摘要: #pragma warning (disable:4786)#include <string>#include <iostream>#include <map>using namespace std;int main(){ string name[]={"tian","dsp","su","chu"}; map<int,string> mapname; for (int i=0;i<4;i++) { mapname.insert(pair<int,stri 阅读全文
posted @ 2012-07-26 15:48 Dsp Tian 阅读(588) 评论(0) 推荐(0)
上一页 1 ··· 59 60 61 62 63 64 65 66 67 ··· 79 下一页