.profile
io2.c
/* Basic I/O: fopen(), fprintf() to, and fclose() a file. */ /* Compile: cc -g -ansi -pedantic -Wall -O2 -o io2 io2.c */ /* Run: ./io2 */ #include <stdio.h> int main() { char *my_filename; FILE * my_stream; my_filename = "junk.txt"; my_stream = fopen(my_filename, "w"); fprintf(my_stream, "Just a little hello from fprintf().\n"); /* fclose() returns 0 on success, EOF on error */ if ((fclose (my_stream)) == EOF) { fprintf(stderr, "Whoops, something went wrong"); return 1; } fprintf(stdout, "Check the created file '%s'.\n", my_filename); return 0; }