#include /* C example: K&R C book, pp. 160-161, 242 */ #include int main() { FILE *out1; FILE *out2; out1 = fopen("outfile1", "w"); /* overwrite */ if (out1 == NULL) { fprintf(stderr, "can't open outfile1\n"); return EXIT_FAILURE; } out2 = fopen("outfile2", "a"); /* append */ if (out2 == NULL) { fprintf(stderr, "can't open outfile2\n"); return EXIT_FAILURE; } fprintf(out1, "hello\n"); fprintf(out2, "goodbye\n"); fclose(out1); fclose(out2); return EXIT_SUCCESS; }