I'm finding issue with my current program. I built the program so that it reads an input code from a file and it is also supposed to display only the code's appropriate salary. However, for some reason, everything I've tried only results in all the salaries being pulled together, not one individually. Am I overlooking something incredibly simple here?
#include <iostream>
#include <string>
#include <fstream>
using namespace std;
int main()
{
//displays the payrolls stored in the Intermediate24.txt
string payRoll = "";
string code = "";
//create file object and open the file
ifstream inFile;
inFile.open("Intermediate24.txt", ios::in);
//determine whether the file was opened
if (inFile.is_open())
{
//enter a payroll code
cout << "Please enter a code: ";
cin >> code;
//read a code
getline(inFile, code, '#');
getline(inFile, payRoll);
while (!inFile.eof())
{
//display the payroll
cout << code << "." <<
payRoll << endl;
//read another code
getline(inFile, code, '#');
getline(inFile, payRoll);
}//end while
//close the file
inFile.close();
}
else
cout << "File could not be opened" << endl;
//end if
system("pause");
return 0;
} //end of main function