In the below code, I\'m running into an error when I try to get the user to input their name. My program just skips it over and goes right over to making the function calls with
from looking at code showMenu
function has problem. and it's not returning asccii equivalent of '1'
that is: 31 integer. try printing value returned by showmenu
. you will get that
UPDATE:
It is because cin
in delimited by ' '
(whitespace) and getline
by '\n'
character, so when enter name and press enter cin
in showmenu
will consume whole string except '\n'
from istream
and that is read by getline
. to see this when it ask for choice enter string like 1 myname
(1 whitespace myname)and press ENTER will display name. now cin
will read 1 in choice
and myname
in name by getline
.