Hello I been working on this code but I cant get it too loop back untill all values in this file are printed out on the screen. The code will print out just the "cout" statements only one time on screen but will not produce the values. Also it wont loop back and give me the results of the whole list. Also there is a warning on thecompiliar that says... 'rec' is assigned a value that is never used. Here is the code any help will be greatly appreciated. Thank you
Code:
void main()
{
int z;
cout<<"test"<<endl;
AcademicRec();
cin>>z;
}
void AcademicRec() //Reading the AcademicRec's File
{
ifstream acctFile ("Accounts1.dat"); // This is the accounts database file
char line[200];
char rec = 0;
int z;
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;
}
}
rec++;
cin >>z;
}