Opening files for reading and writing
We can now create a program to open a file for reading and another file for writing. This is where our file I/O exploration will begin and continue through the remaining chapters of this book. The following program is our starting point:
#include <stdio.h>
#include <stdlib.h> // for exit()
#include <string.h> // for strerror()
#include <sys/errno.h> // for errno
int main( void ) {
FILE* inputFile;
FILE* outputFile;
char inputFilename[] = "./input.data";
char outputFilename[] = "./output.data";
inputFile = fopen( inputFilename , "r" );
if( NULL == inputFile ) {
fprintf( stderr, "input file: %s: %s\n",
...