This 50-point project must be submitted as a single file to the Moodle submission page for Project P9 by 11:00 PM on Tuesday, 1 November.
Your program will work from a single command line argument that will
be stored in main
's argv[1]
.
If main
's argc
parameter is not two,
your program should print an error message to stderr
and then return EXIT_FAILURE
.
Your program should then use fopen
to open a file for
reading using the string passed in argv[1]
as the
file name. If the file open fails, this is, returns NULL
,
your program should print a useful error message and
then return EXIT_FAILURE
.
Your program should then read the lines of the file.
If an input line contains the word
Asheville, then the input line should be written
to standard output (stdout
) with all occurances of
the word Asheville replaced by Raleigh.
If an input line does not contain the word Asheville,
the line should not be printed.
You may assume that no line has more than 80 characters
in writing your program. You may also assume that either the
input file has no characters or that the last character of the
input file is the '\n'
end-of-line.
When Asheville appears within the input file, it is considered a word only if both of the following conditions are satisfied.
Use the functions isspace
and ispunch
to determine when a character is white-space or punctuation.
This is a line and this one has one Asheville in the middle nothing here This has xAsheville -- should not be printed and this with with AshevilleX should not be printed Asheville starts this one and this one ends with Asheville Asheville ,Asheville, NC Here an Asheville and there an Asheville every where the last line