1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
|
void printReport()
{
string name, address, city, state; // not needed >> = "" ;
int zip, visa_Num = 0 ;
/* Not necessary:
ifstream inFile ;
inFile.open("VisaCard.txt", ios::in); */
// Should just be:
ifstream infile("VisaCard.txt"); // Note: no ios::in, an ifstream is always ios::in, always, can't be changed.
if(inFile.is_open())
{
// PRIMING READ
displayTitle();
getline(inFile, name, '#') ;
//while(!inFile.eof()) // You really shouldn't use eof() to control your read. Use the actual read operation instead,. (See note 1.)
while(getline(infile, name, '#'))
{
inFile.ignore(1); // What are you trying to ignore here?
getline(inFile, address, '#') ;
getline(inFile, city, '#');
getline(inFile, state, '#') ;
inFile >> zip ;
inFile >> visa_Num;
inFile.ignore(2); // What are you trying to ignore here?
displayReport(name, address, city, state, zip, visa_Num);
// getline(inFile, name, '#'); // Not needed when using the read to control the loop.
} // END WHILE
} // END IF
else
{
cout << " File Could not be Opened " << endl ;
}
// inFile.close(); Not necessary, let the destructor do it's job.
//system("pause"); // Why are you pausing here??
}
|