大家好,本人刚学了点文件指针,现有个问题: 本意是:我在D盘有个文件data.txt,其中有这样的字符:I like C.那现我想通过写一段程序在D盘建一个文件:data2.txt,并把 I like C.复制过来。程序如下,但运行后出现无数个y,且头上还有两点,请大伙帮个忙,给个解释,谢谢!
main() { FILE *f,*f2; char c; f=fopen("d:\\data.txt","r"); f2=fopen("d:\\data2.txt","w"); if(f==NULL||f2==NULL) { printf("This file doesn't exist,please creat it."); exit(1); } c=fgetc(f); while(!feof(f)) { fputc(c,f2); c=fgetc(f); } while(!feof(f2)) putchar(fgetc(f2)); fclose(f); fclose(f2); getch(); }