R
roger.a.banks
I've written a little command line utility. So far it just reads from
stdin using cin and outputs to stdout using cout. I would like to
generalize it some by being able to specify input and output files on
the command line while retaining the ability to use stdin and stdout
if no files are specified on the command line. My thinking is that I
need to replace all instances of cin and cout with some generic names
like 'infile' and 'outfile' and then set them to point to either (cin
| cout) or the file specified on the command line after parsing the
command line, but I can't seem to find the correct way to code this.
Is this the correct approach and, if so, could someone post a hint and/
or sample code? Thanks!
stdin using cin and outputs to stdout using cout. I would like to
generalize it some by being able to specify input and output files on
the command line while retaining the ability to use stdin and stdout
if no files are specified on the command line. My thinking is that I
need to replace all instances of cin and cout with some generic names
like 'infile' and 'outfile' and then set them to point to either (cin
| cout) or the file specified on the command line after parsing the
command line, but I can't seem to find the correct way to code this.
Is this the correct approach and, if so, could someone post a hint and/
or sample code? Thanks!