I have the following database:
101884622 Johnson,Jack,Michael 239483
441314978 Meyers,Sally,Elaine 019383
684736222 Smallwood,Jason,Joseph 293812
387240551 Ward,Richard,Charles 472041
273639944 Vapson,Michelle,Regina 112039
654230472 Wilson,Donald,Anthony 528763
736459533 Utzig,Jacob,William 614524
687130851 Brown,Betty,Mary 079813
I am trying to use ifstream
to make C++ output the member's first middle and last name according to the text file. How can one acomplish this? Here is my code
int main() {
double socialSN = 0;
string memberFName = "";
string memberMName = "";
string memberLName = "";
double memberID = 0;
char div = ',';
ifstream infile;
infile.open ("salary_database2.txt");
if(!infile) {cout << "Error: File not found or corrupt. "<< endl; return 1;}
while(infile >> socialSN >> memberLName >> div >> memberMName >> div >> memberFName >> memberID) {
cout << setprecision(0) << fixed;
cout << memberFName << " " << memberMName << " " << memberLName << endl;
}
return 0;
}
The compiler shows no errors. The program just doesn't show anything.