Summary
In this chapter, we once again demonstrated the importance of developing a complex program step by step from simpler yet operational programs. Here, we took the program from Chapter 22, Working with Files, and built upon it to create a template program, getoptFiles.c
. We saw that getoptFiles.c
can read from either stdin
or a file and can write to either stdout
or another file. We then built upon getoptFiles.c
, which did little else than open streams, to read lines of text representing names and output those lines as they were read. In the process of doing that, we learned about the subtleties of the fgets()
and fputs()
functions and how to use them to our advantage by wrapping each in a more capable function of our own.
Lastly, we took the concepts of sorted names from Chapter 22, Working with Files, and applied them to files using dynamic memory structures to accommodate large and unknown numbers of data...