Exercise to check the file status:
Get a copy of the
cp /net/data/ftp/pub/class/110/ftp/cpp/io/iodemoP.cpp iodemoP.cpp
or, using your mouse to copy and paste the program into Pico, or
using the Hercules command-line ftp program to copy this file from the CS Department's anonymous ftp site.
The path: pub/class/110/ftp/cpp/io The file:
This program demonstrates how to use File I/O. It reads four floating point values from the input data file and output these numbers to an output file in reverse order.
Add in code to test the state of the input stream and send out message "Connot open the input file successfully".
Hint: if ( !inData )
See what will happen without the input data file
Use Pico to create the input data file called
just type in four numeric values, one per line.
Compile and run the program.
Fix the program according to the error messages if there are any mistakes.
Copyright: Department of Computer Science, University of Regina.