01.01.2013 Views

AT&T UNIX™PC Unix System V Users Manual - tenox

AT&T UNIX™PC Unix System V Users Manual - tenox

AT&T UNIX™PC Unix System V Users Manual - tenox

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

GETC ( 3S ) GETC ( 3S )<br />

NAME<br />

getc, getchar, fgetc, getw - get character or word from stream<br />

SYNOPSIS<br />

#include <br />

int getc (stream)<br />

FILE •stream;<br />

int getchar ()<br />

int fgetc (stream)<br />

FILE •stream;<br />

int getw (stream)<br />

FILE •stream;<br />

DESCRIPTION<br />

Getc returns the next character (i.e. byte) from the named input<br />

stream. It also moves the file pointer, if defined, ahead one character<br />

in stream. Getc is a macro and so cannot be used if a function<br />

is necessary; for example one cannot have a function pointer<br />

point to it.<br />

Getchar returns the next character from the standard input<br />

stream, stdin. As in the case of getc, get char is a macro.<br />

Fgetc performs the same function as getc, but is a genuine function.<br />

Fgetc runs more slowly than getc, but takes less space per<br />

invocation.<br />

Getw returns the next word (i.e. integer) from the named input<br />

stream. The size of a word varies from machine to machine. It<br />

returns the constant EOF upon end-of-file or error, but as that is<br />

a valid integer value, feof and ferror(3S) should be used to check<br />

the success of getw. Getw increments the associated file pointer,<br />

if defined, to point to the next word. Getw assumes no special<br />

alignment in the file.<br />

SEE ALSO<br />

fclose(3S), ferror(3S), fopen(3S), fread(3S), gets(3S), putc(3S),<br />

scanf(3S).<br />

DIAGNOSTICS<br />

These functions return the integer constant EOF at end-of-file or<br />

upon an error.<br />

BUGS<br />

Because it is implemented as a macro, getc treats incorrectly a<br />

stream argument with side effects. In particular, getc( •f++)<br />

doesn't work sensibly. Fgetc should be used instead.<br />

Because of possible differences in word length and byte ordering,<br />

files written using putw are machine-dependent, and may not be<br />

read using getw on a different processor.<br />

- 1 -

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!