I have access to a completed c++ program, but I don't understand one aspect of it. To me, it seems as if an extra getline is used[to extract the string dummy from file]. However, when I comment out that getline statement, my numbers are wrong. When I leave the statement in, and cout the value of dummy, nothing is returned. And I know the value of dummy is "\0", but why would I even need to manually extract that? I've seen this in a few other programs, but in others it's absent. Why must we getline twice?
Here's the program:
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
const double INTEREST = 0.075 / 12.0 + 1.0;
int main()
{
string id,
dummy;
int months;
double principle,
totalOldPrinciple=0,
totalNewPrinciple=0;
ifstream inFile;
inFile.open("pa6.dat");
if (!inFile)
{
cout << "No data file!" << endl;
exit(1);
}