// fputs example // source: http://www.cplusplus.com/ #include #include #define SENTLEN 80 int main() { FILE *pFile; char sentence[SENTLEN]; printf("Enter sentence to append: "); fgets(sentence, sizeof(sentence), stdin); // write to file pFile = fopen("myfile.txt","a"); fputs(sentence, pFile); // also to the terminal fputs (sentence, stdout); fclose(pFile); return EXIT_SUCCESS; }