getchar, getwchar
Go Up to stdio.h Index
Header File
stdio.h
Category
Console I/O Routines
Prototype
int getchar(void);
wint_t getwchar(void);
Description
Gets character from stdin.
getchar is a macro that returns the next character on the named input stream stdin. It is defined to be getc(stdin).
Note: Do not use this function in Win32 GUI applications.
Return Value
On success, getchar returns the character read, after converting it to an int without sign extension.
On end-of-file or error, it returns EOF.
Example
#include <stdio.h> int main(void) { int c; /* Note that getchar reads from stdin and is line buffered; this means it will not return until you press ENTER. */ while ((c = getchar()) != '\n') printf("%c", c); return 0; }
Portability
POSIX | Win32 | ANSI C | ANSI C++ | |
---|---|---|---|---|
getchar |
+ |
+ |
+ |
+ |
getwchar |
+ |
+ |
+ |