really bizarre.. compiler skipping gets()...
I really have no clue of what's going on, so here's part of the code
Code:
void Queue::showMenu(){
int choice;
do{
cout <<n<<"This program will add people into a line and then retrieve them in the first-in first-out order."<<n;
cout <<"If you want to check the line, type 1.\nIf you want to add someone into the line, type 2.\nIf you want to take the first person out of the line, type 3.\nIf you want to delete someome from the line, type 4(-1 to quit):\n-> ";
cin >> choice;
if(choice==-1){
break;
}
else if(choice==1){
cout <<n;
q1.showLine();
break;
}
else if(choice==2){
cout<<n<<"Please, type in the person\'s name:";
gets(str);
break;
}
else if(choice==3){
q1.moveLine(*Line);
break;
}
else if(choice==4){
q1.deleteFromLine(str);
break;
}
}while(!*str);
}
Well... I have not finished writing the programme yet, but look right here...
Code:
else if(choice==2){
cout<<n<<"Please, type in the person\'s name:";
gets(str);
break;
}
when the programme is actually being run it skips gets(str); and finishes... but if I wrote gets(str);gets(str);... or do{gets(str);}while(!*str); it would work...
but even though, this is really bugging me, could someone explain me why it is doing that?
thanks!