// Append text to a file using fputs() #include int main() { char text[50]; FILE *file_ptr; // 1. declare a FILE pointer file_ptr = fopen("lines.txt", "a"); // 2. open file if( file_ptr != NULL ) // 3. test { printf("File opened.\nEnter text to append: "); gets(text); fputs(text, file_ptr); // 4. write text fclose(file_ptr); // 5. close the file return 0; } else{ printf("Unable to open file.\n"); return 1; } }