多寫的字符似乎就是EOF,但是不能確定。
//: test05.c
#include <stdio.h>
#include <stdlib.h>
int main() {
system("cls");
FILE* f;
char buf[0x1000];
char* p = buf;
f = fopen("test05.c", "r");
while(1) {
if(feof(f))
break;
*p++ = fgetc(f);
}
printf("%s", buf);
printf("\n");
fclose(f);
f = fopen("test05.txt", "w");
p = buf;
// while(*p) { //用這個語句雖然也能成功寫入文本文件,但會多寫入至少一個字節。
// fputc(*p++, f);
// }
while(*p != EOF) {
fputc(*p++, f);
}
fclose(f);
}
///:~