Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

getchar_unl(3s) [hpux man page]

getc(3S)																  getc(3S)

NAME
getc(), getc_unlocked(), getchar(), getchar_unlocked(), fgetc(), getw(), getw_unlocked() - get character or word from a stream file SYNOPSIS
Obsolescent Interface DESCRIPTION
Returns the next character (i.e., byte) from the named input stream, as an unsigned character converted to an integer. It also moves the file pointer, if defined, ahead one character in stream. is defined as and are defined both as macros and as functions. Same as but is a function rather than a macro. is slower than but it takes less space per invocation and its name can be passed as an argument to a function. returns the next word (i.e., in C) from the named input stream. increments the associated file pointer, if defined, to point to the next word. The size of a word is the size of an integer and varies from machine to machine. assumes no special alignment in the file. and are identical to and respectively except they do not perform any internal locking of the stream for multithreaded applications. Obsolescent Interface gets character or word from a stream file. APPLICATION USAGE
and interfaces should be used by multithread applications which have already used to acquire a mutual exclusion lock for the stream (see flockfile(3S)). After or is applied to a stream, the stream becomes byte-oriented (see orientation(5)). RETURN VALUE
Upon successful completion, and return the next byte from the input stream pointed to by stream for and If the stream is at end-of-file, the end-of-file indicator for the stream is set and EOF is returned. If a read error occurs, the error indicator for the stream is set, is set to indicate the error and EOF is returned. When the file corresponding to an open stream gets extended after the end-of-file is reached, any subsequent calls to these functions will succeed and the end-of-file indicator will remain set. However, in the UNIX2003 standards environment (see standards(5)), these functions will return EOF and the end-of-file indicator will still remain set. Upon successful completion, and return the next word from the input stream pointed to by stream. If the stream is at end-of-file, the end- of-file indicator for the stream is set and and return EOF. If a read error occurs, the error indicator for the stream is set, and and return EOF and set to indicate the error. and can be used to distinguish between an error condition and an end-of-file condition. ERRORS
and fail if data needs to be read into the stream's buffer, and: The flag is set for the file descriptor underlying stream and the process would be delayed in the read operation. The file descriptor underlying stream is not a valid file descriptor open for reading. The read operation was terminated due to the receipt of a signal, and either no data was transferred or the implementation does not report partial transfer for this file. A physical I/O error has occurred, or the process is a member of a background process and is attempting to read from its controlling terminal, and either the process is ignoring or blocking the signal or the process group of the process is orphaned. Additional values may be set by the underlying function (see read(2)). WARNINGS
and are implemented both as library functions and macros. The macro versions, which are used by default, are defined in To obtain the library function either use a to remove the macro definition or, if compiling in ANSI-C mode, enclose the function name in parenthesis or use the function address. The following example illustrates each of these methods : If the integer value returned by or is stored into a character variable then compared against the integer constant the comparison may never succeed because sign-extension of a character on widening to integer is machine-dependent. The macro version of incorrectly treats a stream argument with side effects. In particular, does not work sensibly. The function version of or should be used instead. Because of possible differences in word length and byte ordering, files written using are machine-dependent, and may be unreadable by on a different processor. Reentrant Interfaces If is defined before including the locked versions of the library functions for and are used by default. is an obsolescent interface supported only for compatibility with existing DCE applications. New multithreaded applications should use SEE ALSO
read(2), fclose(3S), ferror(3S), flockfile(3S), fopen(3S), fread(3S), gets(3S), putc(3S), scanf(3S), orientation(5), standards(5), thread_safety(5). STANDARDS CONFORMANCE
getc(3S)
Man Page