Q1: Why is the compiler complaining when I call convert() like this?
convert( input_filename, output_filename );
The declaration is: void convert ( ifstream &in_fs, ofstream &out_fs);
Q2: When I run my program, why do I just get the prompt again?
--------------------------------------------------------------------------------
Q1: Why is the compiler complaining when I call convert() like this?
convert( input_filename, output_filename );
The declaration is: void convert ( ifstream &in_fs, ofstream &out_fs);
A1: convert is expecting an ifstream object and an ofstream object.
Refer to the I/O Streams handout, back page, top example program.
ifstream ifs;
ofstream ofs;
Therefore the call should be
convert( ifs, ofs );
You use the input_filename with the open() member function call:
ifs.open (input_filename);
ofs.open (output_filename);
--------------------------------------------------------------------------------
Q2: When I run my program, why do I just get the prompt again?
A2:
1) Copy the sample input file into your home directory:
"cp Assignments/p12.in . "
2) Refer to your I/O Streams handout back page, top example.
Your type in input file name: "p12.in"
Your type in output file name: "junk"
Then open p12.in with "ifs.open(infile);"
Then open junk with "ofs.open(outfile);"
3) If all of your output is given to ofstream object eg. ofstream ofs
( "ofs.put(ch);" ),
then look at that file after your program has run by typing
"more junk"
--------------------------------------------------------------------------------