What is the difference between the functions getch, getchar, scanf in the C programming language?
2 answers
scanf - formatted input. It can read several values of different types and formats at once (relevant for floating-point numbers)
getchar - reads one character from standard input (console). If the character is EOF, then sets the end of input flag for standard input ( stdin ).
getch - just reads one character from the console. Not included in the standard, implementations for different compilers may vary. MSDN recommends using _getch from the standard.
- 2> Petrosyan. It is not clear why ask a question, the answer to which you can google in a minute. - nitrocaster
- oneIf the question about the difference between
getcharandgetchstill has some kind of logic to it, then the question about the difference ofscanffrom them for my taste is quite strange. The argument list is different, the return value is different, but in general everything else. - VladD 1:51 pm - 2@Flammable, it is not clear why petrosyanit in response to a question, the answer to which you can google in a minute. - etki 2:13 pm
- one@Etki: because the author of the question was too lazy to google for a minute? - VladD
- one"MSDN recommends using
_getchfrom the standard." But in the standard there is neithergetchnor_getch. - AnT
|
About getch and getchar .
But the differences with scanf look in the documentation.
|
getchfunction. - AnT