read a file than produce 2 output files(HELP) 
Author Message
 read a file than produce 2 output files(HELP)

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



Tue, 28 Aug 2001 03:00:00 GMT  
 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



Tue, 28 Aug 2001 03:00:00 GMT  
 read a file than produce 2 output files(HELP)
<< need  some help >>

With what part? The part where you turn on your computer? That is normally
done with the switch on the front panel. No C compiler? There are free ones
posted on the Internet.

Once you have written your code, please post the parts that don't work and
ask for help.
--

Paul Lutus
www.arachnoid.com

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



Tue, 28 Aug 2001 03:00:00 GMT  
 read a file than produce 2 output files(HELP)
: 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.

Take a swing through DejaNews; reading and writing strings from files
is not an uncommon exercise.  However, it's amazingly tedious writing
such code for the nth time, so you'll get more help if you try and
understand it on your own first, then post specific questions here.

Will



Wed, 29 Aug 2001 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. read a file than produce 2 output files(HELP)

2. Reading a file & output a file

3. Please Help: Reading & Writing from/to a Unicode File produces garbage in output file

4. Help! reading from a file and output

5. reading output produced by an archive

6. reading output (stdout) produced by an archive

7. Problem producing rtf file for help project

8. fgets reading a configuration file: compiles OK but output wrong

9. Read command output file

10. Read and Output RTF file

11. Sorting output to diff files into a single file

12. output file as true 3-d file

 

 
Powered by phpBB® Forum Software