I am working on an assignment and was wanting to know if one of u guys could let me know if I have 1. correct before I go to 2.
Here are the instructions...
1. read in the data then displayed the data.
2 Add the following
a. add a data structure to hold the data
b. read in the data from the input file
c. store the data in the data structure
d. write the data to a output file!
here is my code
#include <iostream>
#include <fstream>
#include <cmath>
using namespace std;
//Start main
int main()
{
string filename = "exam.txt"; // Create Var to hold file name
char inputline[80]; // Buffer to hold line just read
ifstream inFile; // Input file object
// Open the input file.
inFile.open("exam.txt");
// Test for errors.
if (!inFile)
{
cout << "Error opening " << filename << endl;
exit(EXIT_FAILURE);
}
// Read through file & list names
// Read and process the input file.
while (!inFile.eof())
{
// Read the string from inFile.
inFile.getline(inputline, 80, '\n');
// Display the line.
cout << inputline << endl;
}
return 0;
}