The program asks the user what they want to do by selecting their choice from the MENU. even in case 1. the program asks the user to input physician name ,but as I do it only works for single character for example.if I input physician name <Sisay> the loop goes infinite but If I put only one letter <S> it works fine.How can I modify the program with out using struct.
thank you for your help !
************************************************
//program to write the information of patients registered
// and physician available in the hospital.The program asks
//the user to register physician,register patient,
//list all available physicians and lisit all registered patients
// depending on the interest of the user.
#include<iostream>
#include<cstring>
using namespace std;
int main()
{
int i;
char name[12],*nam=&name[0];
int ch,n,phy_id[100],phy_workex[100];
char phy_name[100],phy_spec[100];
char *phyname=&phy_name[0];
char pat_name[100],pat_gender[10],pat_case[50],ass_phy[12];
char *patname=&pat_name[0];
int m,pat_age[4],pat_cardno[20],pat_date[4];
do
{
cout<<"\t\t\t TASK SELECTION WINDOW \n";
cout<<"\t\t\t ********************* \n";
cout<<"\t\tWhat would you like to do ?\n";
cout<<"\t\t Please enter the number you choice \n";
cout<<"\t\t 1.Register a physician/s \n";
cout<<"\t\t 2.Register a patient/s \n";
cout<<"\t\t 3.List all available physicians \n";
cout<<"\t\t 4.List all registered patients \n";
cout<<"\t\t 5.Quit a program \n";
cout<<endl;
cout<<"Please enter your choice !\n";
cin>>ch;
switch(ch)
{
case 1:
cout<<"\t How many physician you want to register ?\n";
cout<<"\t------------------------------------------\n";
cin>>n;
cout<<"Enter name,id,specification and work experiance of "<<n<<"physicians"<<endl;
cout<<"--------------------------------------------------------------"<<endl;
for( i=0;i<n;i++)
{
cout<<"\nEnter physician "<<i+1 <<" name :";
cin>>phy_name[i];
cout<<"Enter physician "<<i+1<<" id :";
cin>>phy_id[i];
cout<<"Enter physician "<<i+1 <<" specification :";
cin>>phy_spec[i];
cout<<"Enter physician "<<i+1 <<"work experiance :";
cin>>phy_workex[i];
cout<<endl;
}
break;
case 2:
cout<<"\t How many patient you want to register ?\n";
cout<<"\t -------------------------------------- \n";
cin>>m;
cout<<"Enter name,age,gender,card no,case,date and assigned physician of"<<m<<"patients"<<endl;
cout<<"-------------------------------------------------------------------------"<<endl;
for( i=0;i<m;i++)
{
cout<<"\n Enter patient "<<i+1<<" name :";
cin>>pat_name[i];
cout<<"\n Enter patient "<<i+1<<" age :";
cin>>pat_age[i];
cout<<"\nEnter patient "<<i+1<<" gender :";
cin>>pat_gender[i];
cout<<"\n enter patient "<<i+1<<" card number :";
cin>>pat_cardno[i];
cout<<"\n Enter patient"<<i+1<<" case :";
cin>>pat_case[i];
cout<<"\n Enter patient "<<i+1<<" date :";
cin>>pat_date[i];
cout<<"\n Enter patient "<<i+1<<" assigned physician :";
cin>>ass_phy[i];
cout<<endl;
}
break;
case 3:
cout<<"\t program to list all available physicians \n";
cout<<"\t ---------------------------------------- \n";
cout<<"Number "<<" name "<<"\t"<<"ID" <<"\t"<<"specification "<<"\t"<<"work exepriance \n";
for(i=0;i<n;i++)
{
cout<< i+1<<"\t"<<phy_name[i]<<"\t"<<phy_id[i];
cout<<"\t"<<phy_spec[i]<<"\t\t"<<phy_workex[i];
cout<<endl;
}
break;
case 4:
cout<<"\t\tprogram to list all registered patients \n";
cout<<"\t\t****************************************\n";
cout<<"number "<<"\t"<<"age"<<"\t"<<"gender"<<"\t"<<"card number ";
cout<<"\t"<<"case"<<"\t"<<"date"<<"\t"<<"assigned physician";
cout<<endl;
for( i=0;i<m;i++)
{
cout<< i+1<<"\t"<<pat_name[i]<<"\t"<<pat_age[i]<<"\t"<<pat_gender[i];
cout<<"\t"<<pat_cardno[i]<<"\t"<<pat_case[i]<<"\t"<<pat_date[i];
cout<<"\t"<<ass_phy[i]<<endl;
}
break;
case 5:
cout<<"\tCongratulation you finished your program !\n";
cout<<"\t-----------------------------------------\n";
return 0;
break;
}
}
while(true);
return 0;
}