
read a file than produce 2 output files(HELP)
To open a file, use fopen(). How you specify the second parameter dictates
whether you are opening it for read, write, or both. It sounds like you
want to open one file for reading and two files for writing.
fopen() returns NULL if it fails to open the file. You should check for
this. If it happens, report it to the user, clean up (ie if it happens on
the second or third fopen(), close the file(s) that you did open
successfully), and make the program stop gracefully.
To read from a file, use fgets() if it's a text stream (which it almost
certainly is for this assignment).
To write to a file, you can use fprintf().
To close a file when it's finished with, use fclose().
All those functions are in stdio.h.
To convert a string to upper case, you can call toupper() in a loop.
To convert a string to lower case, you can call tolower() in a loop.
tolower and toupper are in ctype.h.
Now go write your program. In future, if you get stuck, post your code, not
just a spec.
--
Richard H
#include "sig.h"
Quote:
> read a file than produce 2 output files(HELP)
> I have to write a program that reads a file that contains names. The
program
> must read all names until the end of file. Then it has to produce one
file
> that puts all users names in upper case and a second file that puts all
> users names in lower case. Blank lines in the input file should not be
> written to the output file.
> need some help