I have 2 functions in my main(). When I call the first function void patient_main_menu(); it will leave me input all the required fields and it also will print to screen EXACTLY what I had inputed originally.

When the second function is called void doctor_main_menu(); it SKIPS/ Will not leave me INPUT the first field. I dont understand what I am doing wrong as it should be similar to the 1st function.

thx in advance for any advice

TIm
(main file attached for clarity)

#include <iostream>
#include <stdlib.h>
#include <string.h>
#include "patient.h"
#include "list.h"
#include "doctor.h"

void patient_main_menu();
void doctor_main_menu();

doctor DA[5];
static int i=0;
    
int main(int argc, char *argv[])
{
  
  
  patient_main_menu();
  
  doctor_main_menu();
  
  
  system("PAUSE");	
  return 0;
}



void patient_main_menu()
{

  char name[30];
  char dob[10];
  char illness[20];
  int t=1;
  int priority;
  int wardno;
  
  Sequence S;
  patient P;

  cout<<"Enter name of Patient:"<<endl;
  cin.getline(name,30);
  P.set_Name(name);
  
  cout<<"Enter Date of Birth eg 20/11/76:"<<endl;
  cin.getline(dob,10);
  P.set_dob(dob);
  
  cout<<"Enter Illness:"<<endl;
  cin.getline(illness,20);
  P.set_illness(illness);  
  
  cout<<"Enter Priority:"<<endl;
  cin>>priority;
  P.set_priority(priority); 
  
  cout<<"Enter Ward No:"<<endl;
  cin>>wardno;
  P.set_ward_no(wardno);   
        
  S.insert(t,P);    
  S.display();

}

void doctor_main_menu()
{

  char newname[20];
  char address[50];   
  int age;   
  int hours;   
  int payrate; 
  
 
  
  cout<<"Enter name of Doctor:"<<endl;                               //Problem is here with my cin //       cin.getline(newname,20);
  DA[i].set_Name(newname);
  
  cout<<"Enter Address:"<<endl;
  cin.getline(address,50);
  DA[i].set_Address(address);
  
  cout<<"Enter Age:"<<endl;
  cin>>age;
  DA[i].set_Age(age);  
  
  cout<<"Enter Hours Worked:"<<endl;
  cin>>hours;
  DA[i].set_Hours(hours); 
  
  cout<<"Enter Payrate:"<<endl;
  cin>>payrate;
  DA[i].set_Payrate(payrate); 
 
   
  cout<<DA[i].get_Name();
  cout<<DA[i].get_Address();
}

that link solved my problem,

thx

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.