上一页 1 ··· 59 60 61 62 63 64 65 66 67 ··· 79 下一页
摘要: #include <stdio.h>int main(){ char tmpname[L_tmpnam]; char *filename; FILE *tmpfp; filename=tmpnam(tmpname); printf("tmp file is : %s\n",filename); tmpfp=tmpfile(); if(tmpfp) printf("open a tmp file ok\n"); else ... 阅读全文
posted @ 2012-09-09 14:41 Dsp Tian 阅读(576) 评论(0) 推荐(0)
摘要: #include <time.h>#include <stdio.h>int main(){ time_t the_time; (void)time(&the_time); printf("The date is: %s",ctime(&the_time)); return 0;}函数原型:#include <time.h>char *ctime(const time_t *timeval);注:上一篇获得的时间是标准格林威治时间。 阅读全文
posted @ 2012-09-09 14:21 Dsp Tian 阅读(488) 评论(0) 推荐(0)
摘要: #include <time.h>#include <stdio.h>int main(){ struct tm *tm_ptr; time_t the_time; (void) time(&the_time); tm_ptr=gmtime(&the_time); printf("Raw time is %ld\n",the_time); printf("gmtime gives:\n"); printf("date: %02d/%02d/%02d\n", tm_ptr->tm_year, 阅读全文
posted @ 2012-09-09 14:09 Dsp Tian 阅读(477) 评论(0) 推荐(0)
摘要: #include <time.h>#include <stdio.h>#include <unistd.h>int main(){ int i; time_t the_time; for(i=1;i<=5;i++) { the_time=time((time_t*)0); printf("the time is %ld\n",the_time); sleep(2); } exit(0);}时间是从1970年1月1日开始的。函数原型... 阅读全文
posted @ 2012-09-09 14:01 Dsp Tian 阅读(495) 评论(0) 推荐(0)
摘要: #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 阅读(621) 评论(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 阅读(478) 评论(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 阅读(484) 评论(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 阅读(2023) 评论(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 阅读(727) 评论(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)
上一页 1 ··· 59 60 61 62 63 64 65 66 67 ··· 79 下一页