include

include

int main() {

FILE *fp;

char ch;

fp = fopen("file.txt", "r");

if (fp == NULL) {

printf("文件打开失败!\n");

exit(1);

}

while ((ch = fgetc(fp)) != EOF) {

putchar(ch);

}

fclose(fp);

fp = fopen("file.txt", "a");
if (fp == NULL) {
    printf("文件打开失败!\n");
    exit(1);
}
fprintf(fp, "\n这是追加的内容。\n");
fclose(fp);

return 0;

}