Input Problem
ENRIQUEZ
acs60222 at zach.fit.edu
Sat Aug 5 03:55:35 AEST 1989
I am attempting to get single character input for a menu function.
My problem is that the '\n' character ALWAYS gets put into the
buffer (?), so that if the input character is not valid, funny things
happen...
Is there a easy way to "strip" the undesired character from the getchar()
fuction. Program example:
char foobar_menu ();
{
char choice;
do {
printf (" ....menu stuff....");
printf ("Command: );
choice = getchar();
}
while (choice !valid);
return (choice);
}
This works fine if choice is valid. However, if choice not valid, the
menu is printed twice. While I can live with this, I would rather not.
Any help will be appreciated...
mark enriquez acs60222 at zach.UUCP
More information about the Comp.lang.c
mailing list