alright, this program i wrote pops a menu up letting me choose one of the four options, after i choose an option, and it does that function, how do i get the menu to pop back up again so the user can choose another option? instead, my program does the function, then quits. heres my code:
#include <iostream>
using std::cout;
using std::cin;
using std::endl;
struct cardholder
{
char name[10]; //name of student
int SSN; // social security number
char cardtype[10];
float balance;
};
typedef struct cardholder CARD;
void addholder(CARD hold[], int arraycounter);
void printholder(CARD hold[]);
//void findholders(CARD hold[]);
int main()
{
int menuvalue;
int arraycounter = 0;
CARD holder[10];
cout << "Select a option\n";
cout << " 1 Enter a new holder\n";
cout << " 2 Print holders information\n";
cout << " 3 Find holder\n";
cout << " 4 to quit\n";
cin >> menuvalue;
if( menuvalue == 1 )
addholder (holder, arraycounter);
else if ( menuvalue == 2 )
printholder(holder);
//else if (menuvalue == 3)
// find_holders(holder);
return 0;
}
void addholder(CARD hold[], int arraycounter) // add holder function
{
cout << "Enter student name\n";
cin >> hold[arraycounter].name;
cout << "Enter social security number\n";
cin >> hold[arraycounter].SSN;
cout << "Enter card type\n";
cin >> hold[arraycounter].cardtype;
cout << "Enter balance\n";
cin >> hold[arraycounter].balance;
arraycounter++;
}
void printholder(CARD hold[])
{
int social;
social = 0;
cout << "Please enter the social security number\n";
cin >> social;
for (int i = 0; i < 10; i++ )
{
if ( social == hold[i].SSN )
{
cout << "Student SSN: " << hold[i].SSN << endl;
cout << "Student Name: " << hold[i].name << endl;
cout << "Card Type: " << hold[i].cardtype << endl;
cout << "Balance: " << hold[i].balance << endl;
cout << endl;
}
}
}