My program compiles correctly but when I choose one of the options nothing comes up, and I cannot figure out why. If anyone can please help me that would be awesome.... I know my while loop in the main is not completed yet.
I believe my problem is either in the loadlist or the print function.
Please help

here is my code
#include <iostream>
#include <fstream>
#include <iomanip>
#include <string>
using namespace std;
//Struct
struct PublicOfficial
{
string name;
string sob;
int code;
int presorder;
int firstpterm;
int lastpterm;
int vpresorder;
int firstvpterm;
int lastvpterm;
PublicOfficial *nextofficial;
};
//Globals
ifstream infile;
//Prototypes
void LoadList ( PublicOfficial *&firstofficial );
void addOfficial ( PublicOfficial *&firstofficial, PublicOfficial *nextofficial );
void printall ( PublicOfficial *firstofficial, PublicOfficial code);
void printoneterm ( PublicOfficial *firstofficial );
int menu();
int main()
{
PublicOfficial *firstofficial = NULL;
PublicOfficial code;
int choice;
//Calling LoadList
LoadList ( firstofficial );
//Calling Menu
choice = menu();
while ( choice != 7 )
{
if ( choice == 1 )
{
printall ( firstofficial, code );
}
else if ( choice == 2 )
printall ( firstofficial, code );
else if ( choice == 3 )
printall ( firstofficial, code );
else if ( choice == 4 )
printoneterm ( firstofficial );
//Calling Menu
menu();
}
return 0;
} // End of Main
/*********************************************************************
*Loadlist function will accept the head pointer by reference. It will*
*also read in data on the Presidents and Vice Presidents of the US.It*
*will continue to read until the EOF marker. *
*********************************************************************/
void LoadList ( PublicOfficial *&firstofficial )
{
//Opening the file
infile.open( "officials.txt" );
if (!infile)
{
cout << "This file officials.txt does not exist." << endl;
exit(1);
}
PublicOfficial *newofficial;
while (!EOF)
{
newofficial = new PublicOfficial;
newofficial->nextofficial = NULL;
getline(infile, newofficial->name);
getline(infile, newofficial->sob);
infile >> newofficial->code;
if ( newofficial->code == 3 )
{
infile >> newofficial->presorder;
infile >> newofficial->firstpterm;
infile >> newofficial->lastpterm;
infile >> newofficial->vpresorder;
infile >> newofficial->firstvpterm;
infile >> newofficial->lastvpterm;
}
else if ( newofficial->code == 2 )
{
newofficial->presorder = 0;
newofficial->firstpterm = 0;
newofficial->lastpterm= 0;
infile >> newofficial->vpresorder;
infile >> newofficial->firstvpterm;
infile >> newofficial->lastvpterm;
}
else if (newofficial->code == 1)
{
infile >> newofficial->presorder;
infile >> newofficial->firstpterm;
infile >> newofficial->lastpterm;
newofficial->vpresorder = 0;
newofficial->firstvpterm = 0;
newofficial->lastvpterm = 0;
}
//Calling Add Official
addOfficial ( firstofficial, newofficial );
}
//Closing the file
infile.close();
}
/*********************************************************************
*Passes the head points by reference and the newofficial to be added *
*This function will add this node to the end of the linked list, this*
*function will be called from within the while loop for each new *
*official. *
*********************************************************************/
void addOfficial ( PublicOfficial *&firstofficial, PublicOfficial *newofficial )
{
PublicOfficial *Tptr;
Tptr = firstofficial;
firstofficial = newofficial;
newofficial->nextofficial = Tptr;
}
/*********************************************************************
*A menu that will return a valid menu choice based on criteria that *
*the user wishes to see. *
*********************************************************************/
int menu ()
{
int choice;
cout << endl;
cout << "========================================" << endl;
cout << " 1. List Presidents " << endl;
cout << " 2. List Vice Presidents " << endl;
cout << " 3. List Officials that held both " << endl;
cout << " 4. List One Term Presidents " << endl;
cout << " 5. List Presidents by the century " << endl;
cout << " 6. List Presidents by birth place " << endl;
cout << " 7. Quit " << endl;
cout << "========================================" << endl;
cout << "Please enter your selection." << endl;
cin >> choice;
//Checking whether choice is vaild
while ( choice < 1 || choice > 7 )
{
cout << "This is an incorrect choice, please choose another: ";
cin >> choice;
}
return choice;
}
/*********************************************************************
*A function that will pass the header and the code which is 1 and *
*print out all the presidents *
*********************************************************************/
void printall ( PublicOfficial *firstofficial, PublicOfficial code)
{
PublicOfficial *Tptr = firstofficial;
while (Tptr)
{
cout << "Name:" << setw(30) << Tptr->name << endl;
cout << "State:" << setw(30) << Tptr->sob << endl;
if (Tptr->code == 1)
{
cout << "President #:" << setw(30) << Tptr->presorder << endl;
cout << "Presidential Term:" << setw(30) << Tptr->firstpterm
<< " - " << Tptr->lastpterm << endl;
cout << "Vice President #:" << setw(30) << " N/A " << endl;
cout << "Vice Presidential Term:" << setw(30) << " N/A " << endl;
}
else if (Tptr->code == 2 )
{
cout << "President #:" << setw(30) << "N/A" << endl;
cout << "Presidential Term:" << setw(30) << "N/A" << endl;
cout << "Vice President #:" << setw(30) << Tptr->vpresorder << endl;
cout << "Vice Presidential Term:" << setw(30) << Tptr->firstvpterm
<< " - " << Tptr->lastvpterm << endl;
}
else if ( Tptr->code == 3 )
{
cout << "President #:" << setw(30) << Tptr->presorder << endl;
cout << "Presidential Term:" << setw(30) << Tptr->firstpterm
<< " - " << Tptr->lastpterm << endl;
cout << "Vice President #:" << setw(30) << Tptr->vpresorder << endl;
cout << "Vice Presidential Term:" << setw(30) << Tptr->firstvpterm
<< " - " << Tptr->lastvpterm << endl;
}
else
cout << "Error" << endl;
Tptr = Tptr->nextofficial;
}
}