putc_unlocked

Writes a character to the output stream.

Library:LibC
Classification:POSIX
Service:File and Directory I/O
Multithread Use:Unsafe

Syntax

  #include <stdio.h> 
   
  int putc_unlocked (
     int     c,
     FILE   *fp);
  

Parameters

c

(IN) Specifies the byte to be written.

fp

(IN) Points to the file.

Return Values

If successful, returns the character written. If a write error occurs, returns EOF, sets the error indicator for the stream, and sets errno to one of the following:

Decimal

Constant

Description

4

EBADF

The file descriptor is not a valid file descriptor open for writing.

5

ENOMEM

Insufficient storage space is available.

12

ENOSPC

No free space remains on the device containing the file.

24

EAGAIN

The O_NONBLOCK flag is set for the file descriptor, and the process cannot immediately perform the write operation.

25

ENXIO

A request was made of a nonexistent device, or the request was outside the capabilities of the device.

28

EIO

A physical I/O error has occurred.

32

EPIPE

An attempt was made to write to a pipe or FIFO that is not open for reading by any process.

63

EINTR

A signal interrupted the write operation.

71

EFBIG

An attempt was made to write to a file that exceeds the maximum file size.

Remarks

The putc_unlocked function is equivalent to putc, except that it is non-thread safe. It should be used in a multi-threaded program only if it is called while the invoking thread owns the file object, as is the case after a successful call to the flockfile or ftrylockfile functions.

See Also