H
Horst Kraemer
Hi!
I have the following instruction:
char wyp;
scanf("%c",&wyp);
this scanf is in a while loop, and I want it to get EXACTLY one character
each time.
Does anyone knows how to do it?
scanf("%c",&wyp);
will read one character from stdin and store it to wyp. If a read
error occurred or the end of file is reached scanf will return 0 and
nothing will be stored to wyp.
What is your problem and why are you hopeless?
Maybe someone has a different idea to read excatly one character from
keyboard, not necessarily using scanf.
int c:
c = getchar();
if (c==EOF) { /* Either the end of file is reached or a read error
occured */ }
reads one character from stdin. If the end of file is reached or a
read error occured, getchar returns EOF (this is *not* a character).