文件的复制
下面程序为啥不能复制first.txt文件的内容,first01.txt文件存在有内容:程序代码:
#include"stdio.h" #include"stdlib.h" //#define LEN 40 int main() { int i = 0,k =0,ch; FILE *in,*out; //char temp[LEN]; //char name[10]; if(in = fopen("first01.txt","r") ==NULL) { fprintf(stderr,"Usage: first01.txt filename\n"); exit(1); } if(out = fopen("first.txt","w") == NULL) { fprintf(stderr,"Can't create output file.\n"); exit(2); } while((ch = getc(in)) != EOF) { putc(ch,out); } //fgets(temp,8,in); //fputs(temp,out); /************************ if(i % 5 == 0) fputs("\n",out); else fputs(",",out); ************************/ if(fclose(in) == 0 || fclose(out) == 0) fprintf(stderr,"Error in close file.\n"); return 0; }只创建了 first.txt 里面没内容