new line character : scanf and getchar
Date: Mon, 31 Jan 2005 22:08:19 +0800
char c;
int i;
scanf("%d",&i);
c=getchar();
I want to read a integer and a character in 2 lines.
Why the getchar always get the \n character from the last line?????
(Sorry for my newbie question, but where is the FAQ section of the
newsgroup??)
Relevant Pages
- Re: Can C do it ?
... easy to deal with with little a basic knowledge of getchar and the ... characters are still there in the input buffer and this is, sometimes, ... EOF is not a character. ... so that no valid character can be confused with it. ... (comp.lang.c) - Re: user input, getchar, and buffer - For C beginners and those with teaching skills...
... easy to deal with with little a basic knowledge of getchar and the ... characters are still there in the input buffer and this is, sometimes, ... EOF is in int designed ... so that no valid character can be confused with it. ... (comp.lang.c) - Re: user input, getchar, and buffer - For C beginners and those with teaching skills...
... Now again about getchar. ... and so on for each character entered until is pressed down. ... The Linux terminal driver does line canonicalization (in the normal ... For the next one the stdio buffer is now empty, ... (comp.lang.c) - Re: Can C do it ?
... where the user enters data with getchar() handling it like in the code ... and so on for each character entered until is pressed down. ... The Linux terminal driver does line canonicalization (in the normal ... For the next one the stdio buffer is now empty, ... (comp.lang.c) - Re: restar program
... And getchar() may require that an entire line be entered (with ... facility to set input to be character by character. ... Use any of the looping constructs. ... (comp.lang.c) |
|