In Class Lab 2(short lab)
- a short programming
project to be done in one lab session
This lab provides practice for file streams. Suppose that you know that the file inData.txt
contains two integers on the first line, a character on the second line, and a
string message (without spaces) on the third line.
·
Type in the shell of the program below
·
Add the statement that includes the fstream header file in the program
·
Declare variables of type ifstream
and ofstream.
·
Open an input file, called inData.txt and an output
file called outData.txt.
·
Read the data from the input file. After reading the two integers, print the sum
of the two numbers to the output file.
After reading the character, print the character that follows it in the
ASCII sequence to the output file. After
reading the string, print it to the output file.
·
Close the files.
Run your code on different input files, including the one below:
23 57
R
Howdy!
// Programmer: type your name here
// Date completed: type today's date
// Program for practice of streams
#include <iostream>
using
namespace std;
int
main ( )
{
cout<<"Program
to review streams.....\n";
return 0;
}