We begin creating our data file creation program by handling command-line arguments.
In the last chapter, we created a program that expected two filenames on the command line, which were presented via argv; the input file was the first argument and the output file was the second argument. What if we wanted to permit either argument to be omitted? We could no longer rely on argument positioning; we need a way to further identify which argument is input and which argument is output.
To do that, we will revisit the built-in command-line facility getopt(). This facility is older and simpler than getopt_long(), which we demonstrated in Chapter 20, Getting Input from the Command Line. We will specify two options, -i <input filename> and -o <output filename>, neither of which will be required. getopt() does not have the concept of required or optional arguments so we'll have to...