#include#include int main(){ FILE *fp; char ch; if((fp=fopen("testfile", "a")) == NULL){ fprintf(stderr, "Error opening file.\n",fp); exit(1); } printf("Input a string (Ctrl+D to exit):\n"); while((ch=getchar()) != EOF){ fputc(ch, fp); } if(ferror(fp)){ puts("something wrong to read file\n"); }else{ puts("write file success!\n"); } fclose(fp); printf("\n"); return 0;}