Simple console mode menu handling

Started by DMac, July 14, 2011, 08:45:52 PM

Previous topic - Next topic

vedro-compota

mmmm....i need clean input before getting the menu command so the code'll be =
while (getchar() != '\n');
printf("\n%s",mtext );
   ch = getchar();

CommonTater

You can do that... or you can do this...

printf("\n%s",mtext);
scanf(" %c", &ch);


Note the leading space between the " and % in the scanf() ... that tells it to ignore invisible characters (Enter, Tab, spaces, etc) hanging around in the buffer.



vedro-compota

hm. the while (getchar() != '\n'); will stop program if the buffer is empty scanf() can get visible symbol from previous line which was put into input and hadn't been read at the whole - is there any way to check - is the buffer empty before call something which can make it so = http://forum.pellesc.de/index.php?topic=4052.0

vedro-compota

CommonTater , in your previous post you've posted a link to book -is this c specification?

CommonTater

Quote from: vedro-compota on October 21, 2011, 06:20:07 PM
CommonTater , in your previous post you've posted a link to book -is this c specification?

That is the current standard for C programming.


EdPellesC99

There seems to be a problem with downloading the attachment here, and for Timo's thread.

!! Maybe site work is in progress.... Ed

Bitbeisser

Quote from: EdPellesC99 on December 29, 2011, 01:00:12 AM
There seems to be a problem with downloading the attachment here, and for Timo's thread.

!! Maybe site work is in progress.... Ed
Could be. Saw this happen in the tinyPDF thread to me yesterday, but all links that I tried today, just now, are working fine....

Ralf