|
|
Review of fgets() and command line args.
To aid in input/output of strings we have the fgets()
Let us assume that fpcorrectly points to an open file.
However if we are now at the end of that file, then fgets
will return NULL, indicating that an EOF was read.
Otherwise fgetsreads the next line of input (including the
newline) from file fp into the character array line, but no
more than maximum-1characters will be read! The
resulting string (in array line) is terminated with '\0'.
Avoid the functions gets() and puts() on stdin and stdout
Command line arguments
use of int main (int argc, char* argv[]);
Imagine we want to write a program revl which reverses
every line in a file whose name is specified in the command
line. Thus instead of invoking as
revl <datafile
taking input from stdin, we want to type
revl datafile
|
|