putc_unlocked()

write character to stream (not thread-safe) 

Function


SYNOPSIS

#include <stdio.h>

int putc_unlocked(int c, FILE *stream);


DESCRIPTION

The putc_unlocked() function is equivalent to putc(), except that putc_unlocked() is not thread-safe. It writes a byte with value c, cast as an unsigned character, to stream. After putc_unlocked() returns, the character may be held in an internal buffer either until fflush() or fclose() are executed on stream, or until the process executes exit() or abort().

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

c 

Is the character to be written.

stream 

Points to the output stream.


RETURN VALUES

On success, putc_unlocked() returns the value c that it wrote to stream. On failure, it returns EOF and sets errno to one of the following values:

EACCES 

Another process has the file locked.

EBADF 

stream is not a valid stream opened for writing.

EINTR 

A signal interrupted the call.

EIO 

An output error occurred.

ENOMEM 

Memory could not be allocated for internal buffers.

ENOSPC 

An attempt was made to write to a full disk.

ENXIO 

A device error occurred.

EPIPE 

An attempt was made to write to a closed pipe.


CONFORMANCE

POSIX.1 (1996).


MULTITHREAD SAFETY LEVEL

Unsafe.


PORTING ISSUES

If the stream is from a file opened in text mode, linefeed is translated to carriage-return linefeed on output. 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:
abort(), exit(), fclose(), fflush(), flockfile(), fputc(), fputs(), ftrylockfile(), funlockfile(), putc(), putchar(), putchar_unlocked(), puts()


PTC MKS Toolkit 10.1 Documentation Build 15.