1.\" Copyright (c) 1990, 1991 The Regents of the University of California. 2.\" All rights reserved. 3.\" 4.\" This code is derived from software contributed to Berkeley by 5.\" Chris Torek and the American National Standards Committee X3, 6.\" on Information Processing Systems. 7.\" 8.\" %sccs.include.redist.man% 9.\" 10.\" @(#)getc.3 6.8 (Berkeley) 06/29/91 11.\" 12.Dd 13.Dt GETC 3 14.Os 15.Sh NAME 16.Nm fgetc , 17.Nm getc , 18.Nm getchar , 19.Nm getw 20.Nd get next character or word from input stream 21.Sh SYNOPSIS 22.Fd #include <stdio.h> 23.Ft int 24.Fn fgetc "FILE *stream" 25.Ft int 26.Fn getc "FILE *stream" 27.Ft int 28.Fn getchar 29.Ft int 30.Fn getw "FILE *stream" 31.Sh DESCRIPTION 32The 33.Fn fgetc 34function 35obtains the next input character (if present) from the stream pointed at by 36.Fa stream , 37or the next character pushed back on the stream via 38.Xr ungetc . 39.Pp 40The 41.Fn getc 42function 43acts essentially identically to 44.Fn fgetc , 45but is a macro that expands in-line. 46.Pp 47The 48.Fn getchar 49function 50is equivalent to: 51getc with the argument stdin. 52.Pp 53The 54.Fn getw 55function 56obtains the next 57.Em int 58(if present) 59from the stream pointed at by 60.Fa stream . 61.Sh RETURN VALUES 62If successful, these routines return the next requested object 63from the 64.Fa stream . 65If the stream is at end-of-file or a read error occurs, 66the routines return 67.Dv EOF . 68The routines 69.Xr feof 3 70and 71.Xr ferror 3 72must be used to distinguish between end-of-file and error. 73If an error occurs, the global variable 74.Va errno 75is set to indicate the error. 76The end-of-file condition is remembered, even on a terminal, and all 77subsequent attempts to read will return 78.Dv EOF 79until the condition is cleared with 80.Xr clearerr . 81.Sh SEE ALSO 82.Xr ferror 3 , 83.Xr fread 3 , 84.Xr fopen 3 , 85.Xr putc 3 , 86.Xr ungetc 3 87.Sh STANDARDS 88The 89.Fn fgetc , 90.Fn getc 91and 92.Fn getchar 93functions 94conform to 95.St -ansiC . 96.Sh BUGS 97Since 98.Dv EOF 99is a valid integer value, 100.Xr feof 101and 102.Xr ferror 103must be used to check for failure after calling 104.Fn getw . 105The size and byte order of an 106.Em int 107varies from one machine to another, and 108.Fn getw 109is not recommended for portable applications. 110.Pp 111