#include int main(void) { const char *buffer = "This is a test"; FILE *fp = fopen("hello.txt", "w"); if(fp != NULL) { fprintf(fp, "%s\n", buffer); if(ferror(fp)) { fprintf(stderr, "An error occurred while writing the file.\n"); } fclose(fp); } else { fprintf(stderr, "An error occurred while opening the file.\n"); } return 0; }