Ok I was able to solve the problem with the number being printed out at the end of the list of results. BUt now I ran into another problem. Look at the code before to see what I am doing since Im not the best explainer. Well when I ran the first while loop I get the results I wanted however when the other while loop tires to execute to get the results I have to hit a number an enter the number of times that that rec number is..Almost like i am going through spaces. Forinstance i want record 3 so I enter three and hit enter..the first while loop executes and i get the results of name first last name and ex.. however to get the result for the second while loop I must hit a number and enter 3 times to get the rsults. Is there a way I can reset the values of spaces after teh first while loop so that it will automatically take in the record number which i entered in the beginning of the program and run through both loops..Also I have tried putting the second while loop in the first one but i get the same result and problem? Here is teh code I hope the code helps makes sence of my problem..Thank you to all.
Code:
void FinancialRec(char rec) //Reading and Printing Out Financial Records
{
ifstream finaFile ("FinancialRec.dat"); //Input file
ifstream acctFile ("Accounts1.dat"); // This is the accounts database file
ifstream newFile ("Accounts2.dat");
char z;
const float Id1 = 5555; //Password
float record;
char line[100];
cout << "Welcome Please Enter Access Password" <<endl;
cout << "Password: ";
cin >> record;
cout << endl;
if(record == Id1 ) //If password is correct continue
{
cout<< "Please enter students Private ID Number: "; //This gets retrieves the rec #.
cin >> rec;
while(!acctFile.eof())
{
acctFile.getline(line,200);
if(line[0]==rec)
{
acctFile.seekg((acctFile.tellg()-strlen(line)),ios::beg); //seek to the begginning of the line
acctFile.getline(line,200,' '); //get everything up to the space
cout << "Social Security #: " << line << endl;
acctFile.getline(line,200,' ');
cout << "First Name: " << line << endl;
acctFile.getline(line,200,' '); //get everything up to the space
cout << "Last Name: " << line << endl;
acctFile.getline(line,200,' ');
cout << "Phone Number: " << line << endl;
acctFile.getline(line,200,' '); //get everything up to the space
cout << "Home Street: " << line << endl;
acctFile.getline(line,200,' ');
cout << "Home Town: " << line << endl;
acctFile.getline(line,200); //get everything up to the space
cout << "State: " << line << endl;
}
}
while(!finaFile.eof())
{
finaFile.getline(line,100);
if(line[0]==rec)
{
finaFile.seekg((finaFile.tellg()-strlen(line)),ios::beg); //seek to the begginning of the line
finaFile.getline(line,100,' '); //get everything up to the space
cout << "Semester and Year: " << line << endl;
finaFile.getline(line,100,' ');
cout << "School's Total Tuition: " << line << endl;
finaFile.getline(line,100,' '); //get everything up to the space
cout << "Grant/Scholarship Money: " << line << endl;
finaFile.getline(line,100,' ');
cout << "School's Tech Fee: " << line << endl;
finaFile.getline(line,100,' '); //get everything up to the space
cout << "Payments Recieved/Paid: " << line << endl;
finaFile.getline(line,100);
cout << "Remaining Payments: " << line << endl;
}
cin >>z;
}
}
else
{
cout << "Sorry Wrong ID Number" <<endl;
cin >> z;
}
}