#include<conio.h>
#include<iostream.h>
struct info
{
char name[50];
char address[50];
int age;
char gender;
char course[30];
char school[50];
}A;
int main()
{
char ch;
do{
printf("Menu: [S] Set Value\t [O] Open\t[Q] Quit\n");
ch = getch();
switch(ch){
case 'S':
cout<<endl<<"Name: "; gets(A.name);
cout<<endl<<"Address: "; gets(A.address);
cout<<endl<<"Age: "; cin>>A.age;
cout<<endl<<"Gender [M/F]: "; A.gender=getche(); //I think this is the problem...
cout<<endl<<"Course: "; gets(A.course);
cout<<endl<<"School: "; gets(A.school);
break;
case 'O':
cout<<endl<<"Name: "<<A.name;
cout<<endl<<"Address: "<<A.address;
cout<<endl<<"Age: "<<A.age;
cout<<endl<<"Gender: "<<A.gender;
cout<<endl<<"Course: "<<A.course;
cout<<endl<<"School: "<<A.school;
break;
case 'Q': break;
default:
puts("Invalid Input");
}
}while(ch != 'Q');
system("pause");
return 0;
}
***added code tags -jjsaw5***
the problem is in the switch statement. It jump the input functions specially when i input character only....

New Topic/Question
Reply




MultiQuote








|