xref: /csrg-svn/lib/libc/stdio/getc.3 (revision 61180)
1*61180Sbostic.\" Copyright (c) 1990, 1991, 1993
2*61180Sbostic.\"	The Regents of the University of California.  All rights reserved.
320325Smckusick.\"
446090Sbostic.\" This code is derived from software contributed to Berkeley by
550292Sbostic.\" Chris Torek and the American National Standards Committee X3,
650292Sbostic.\" on Information Processing Systems.
750292Sbostic.\"
846090Sbostic.\" %sccs.include.redist.man%
946090Sbostic.\"
10*61180Sbostic.\"     @(#)getc.3	8.1 (Berkeley) 06/04/93
1146090Sbostic.\"
1248351Scael.Dd
1348351Scael.Dt GETC 3
1448351Scael.Os
1548351Scael.Sh NAME
1648351Scael.Nm fgetc ,
1748351Scael.Nm getc ,
1848351Scael.Nm getchar ,
1948351Scael.Nm getw
2048351Scael.Nd get next character or word from input stream
2148351Scael.Sh SYNOPSIS
2248351Scael.Fd #include <stdio.h>
2348351Scael.Ft int
2448351Scael.Fn fgetc "FILE *stream"
2548351Scael.Ft int
2648351Scael.Fn getc "FILE *stream"
2748351Scael.Ft int
2848351Scael.Fn getchar
2948351Scael.Ft int
3048351Scael.Fn getw "FILE *stream"
3148351Scael.Sh DESCRIPTION
3248351ScaelThe
3348351Scael.Fn fgetc
3448351Scaelfunction
3548351Scaelobtains the next input character (if present) from the stream pointed at by
3648351Scael.Fa stream ,
3748351Scaelor the next character pushed back on the stream via
3848351Scael.Xr ungetc .
3948351Scael.Pp
4048351ScaelThe
4148351Scael.Fn getc
4248351Scaelfunction
4346090Sbosticacts essentially identically to
4448351Scael.Fn fgetc ,
4546090Sbosticbut is a macro that expands in-line.
4648351Scael.Pp
4748351ScaelThe
4848351Scael.Fn getchar
4948351Scaelfunction
5048351Scaelis equivalent to:
5148351Scaelgetc with the argument stdin.
5248351Scael.Pp
5348351ScaelThe
5448351Scael.Fn getw
5548351Scaelfunction
5648351Scaelobtains the next
5748351Scael.Em int
5848351Scael(if present)
5948351Scaelfrom the stream pointed at by
6048351Scael.Fa stream .
6148351Scael.Sh RETURN VALUES
6248351ScaelIf successful, these routines return the next requested object
6348351Scaelfrom the
6448351Scael.Fa stream .
6548351ScaelIf the stream is at end-of-file or a read error occurs,
6648351Scaelthe routines return
6748351Scael.Dv EOF .
6848351ScaelThe routines
6948351Scael.Xr feof 3
7020325Smckusickand
7148351Scael.Xr ferror 3
7248351Scaelmust be used to distinguish between end-of-file and error.
7346090SbosticIf an error occurs, the global variable
7448351Scael.Va errno
7546090Sbosticis set to indicate the error.
7646090SbosticThe end-of-file condition is remembered, even on a terminal, and all
7746090Sbosticsubsequent attempts to read will return
7848351Scael.Dv EOF
7928176Skarelsuntil the condition is cleared with
8048351Scael.Xr clearerr .
8148351Scael.Sh SEE ALSO
8248351Scael.Xr ferror 3 ,
8348351Scael.Xr fread 3 ,
8448351Scael.Xr fopen 3 ,
8548351Scael.Xr putc 3 ,
8648351Scael.Xr ungetc 3
8748351Scael.Sh STANDARDS
8848351ScaelThe
8948351Scael.Fn fgetc ,
9048351Scael.Fn getc
9148351Scaeland
9248351Scael.Fn getchar
9348351Scaelfunctions
9448351Scaelconform to
9548351Scael.St -ansiC .
9648351Scael.Sh BUGS
9746090SbosticSince
9848351Scael.Dv EOF
9946090Sbosticis a valid integer value,
10048351Scael.Xr feof
10146090Sbosticand
10248351Scael.Xr ferror
10346090Sbosticmust be used to check for failure after calling
10448351Scael.Fn getw .
10546090SbosticThe size and byte order of an
10648351Scael.Em int
10746090Sbosticvaries from one machine to another, and
10848351Scael.Fn getw
10946090Sbosticis not recommended for portable applications.
11048351Scael.Pp
111