我需要将一个文件的内容复制到另一个文件,然后在屏幕上打印另一个文件的内容。
程序创建文件并复制内容没有问题,但是它不会在屏幕上打印任何内容。
感谢您的时间。
void organizeContent(FILE *file) {
FILE *file_student = fopen("student.txt", "w+");
int ch;
while((ch = fgetc(file)) != EOF)
fputc(ch, file_student);
fflush(file_student);
int ch2;
while((ch2 = fgetc(file_student)) != EOF) {
fputc(ch2, stdout);
return;
}
答案 0 :(得分:1)
在第一个while
循环之后,file_student
流将位于文件的末尾。再次fclose
和fopen
文件,或者rewind
再读回文件。