| | |
problem with cin>> cin.getline
Please support our C++ advertiser: Intel Parallel Studio Home
Thread Solved |
•
•
Join Date: May 2005
Posts: 42
Reputation:
Solved Threads: 0
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)
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();
} Last edited by Dave Sinkula; Dec 3rd, 2005 at 5:07 pm. Reason: Added [code][/code] tags.
![]() |
Similar Threads
- cin.getline problem (C++)
- need help problem with cin.getline method (C++)
- need help problem with cin.getline method (C++)
Other Threads in the C++ Forum
- Previous Thread: Please someone help me
- Next Thread: returning a value from a header file
| Thread Tools | Search this Thread |
api application array arrays based beginner binary bmp c++ c/c++ calculator char char* class classes code compile compiler console conversion count data delete deploy dll download dynamic dynamiccharacterarray email encryption error file format forms fstream function functions game givemetehcodez google graph gui homeworkhelp iamthwee ifstream input int java lib library linkedlist linker list loop looping loops map math matrix memory microsoft newbie news number numbertoword output pointer problem program programming project python random read recursion recursive reference rpg simple sorting string strings temperature template test text text-file tree unix url variable vector video visual visualstudio win32 windows winsock wordfrequency wxwidgets





