getchar_unlocked()

get character from standard input (not thread-safe) 

Function


SYNOPSIS

#include <stdio.h>

int getchar_unlocked(void);


DESCRIPTION

The getchar_unlocked() function gets a character from stdin. It is equivalent to getc_unlocked(stdin).

This function may safely be used in a multi-threaded process only if the invoking thread owns stream, within a scope protected by flockfile() (or ftrylockfile()) and funlockfile().


PARAMETERS

None.


RETURN VALUES

The getchar_unlocked() function returns the next character from stdin. If stdin is at the end of the file, the end-of-file indicator for stdin is set and getchar_unlocked() returns EOF. If a read error occurs, the error indicator for stdin is set and getchar_unlocked() returns EOF. The functions feof() and ferror() can be used to distinguish error conditions from EOF.

On failure, errno is set to one of the following values:

EACCES 

Another process has the file locked.

EBADF 

stdin is not a valid stream opened for reading.

EINTR 

A signal interrupted the call.

EIO 

An input error occurred.

EISDIR 

The open object is a directory, rather than a file.

ENOMEM 

Memory could not be allocated for internal buffers.

ENXIO 

A device error occurred.

EWOULDBLOCK 

The underlying file descriptor is a non-blocking socket and no data is ready to be read.


CONFORMANCE

POSIX.1 (1996).


MULTITHREAD SAFETY LEVEL

Unsafe.


PORTING ISSUES

The routine getchar_unlocked() is implemented as a macro, and hence cannot be used as the value of a pointer to a function.

If the stream is from a file opened in text mode, the line-terminating character sequence carriage return plus linefeed is translated to linefeed. No such translation occurs for files opened in binary mode.


AVAILABILITY

PTC MKS Toolkit for Professional Developers
PTC MKS Toolkit for Professional Developers 64-Bit Edition
PTC MKS Toolkit for Enterprise Developers
PTC MKS Toolkit for Enterprise Developers 64-Bit Edition


SEE ALSO

Functions:
feof(), ferror(), fgetc(), flockfile(), fopen(), ftrylockfile(), funlockfile(), getc(), getc_unlocked(), getchar()


PTC MKS Toolkit 10.4 Documentation Build 39.