.TH getchar() "" "" "STDIO Function (libc)"
.PC "Read character from standard input"
.B "#include <stdio.h>"
\fBint getchar(\|)\fR
.PP
.B getchar()
reads a character from the standard input.
It is equivalent to
.BR getc(stdin) .
.SH Example
The following example gets one or more characters from the keyboard,
and echoes them on the screen.
.DM
#include <stdio.h>
.sp \n(pDu
main()
{
	int foo;
	while ((foo = getchar()) != EOF)
		putchar(foo);
}
.DE
.SH "See Also"
.Xr "getc()," getc
.Xr "libc," libc
.Xr "putchar()" putchar
.br
\*(AS, \(sc7.9.7.6
.br
\*(PX Standard, \(sc8.1
.SH Diagnostics
.B getchar()
returns
.B EOF
at end of file or on read error.
.PP
If you wish to receive characters from the keyboard immediately, without
waiting for the enter key, see the example in the entry for
.BR pipe() .
