up | Inhaltsverzeichniss | Kommentar

Manual page for PUTC(3S)

putc, putchar, fputc, putw - put character or word on a stream

SYNOPSIS

#include <stdio.h>

int putc(c, stream)
char c;
FILE *stream;

int putchar(c)
char c;

int fputc(c, stream)
char c;
FILE *stream;

int putw(w, stream)
int w;
FILE *stream;

DESCRIPTION

putc() writes the character c onto the standard I/O output stream stream (at the position where the file pointer, if defined, is pointing). It returns the character written.

putchar(c) is defined as putc(c, stdout). putc() and putchar() are macros.

fputc() behaves like putc(), but is a function rather than a macro. fputc() runs more slowly than putc(), but it takes less space per invocation and its name can be passed as an argument to a function.

putw() writes the C int (word) w to the standard I/O output stream stream (at the position of the file pointer, if defined). The size of a word is the size of an integer and varies from machine to machine. putw() neither assumes nor causes special alignment in the file.

Output streams are by default buffered if the output refers to a file and line-buffered if the output refers to a terminal. When an output stream is unbuffered, information is queued for writing on the destination file or terminal as soon as written; when it is buffered, many characters are saved up and written as a block. When it is line-buffered, each line of output is queued for writing on the destination terminal as soon as the line is completed (that is, as soon as a NEWLINE character is written or terminal input is requested). setbuf.3v setbuffer(), or setvbuf() may be used to change the stream's buffering strategy.

SEE ALSO

fclose.3v ferror.3v fopen.3v fread.3s getc.3v printf.3v puts.3s setbuf.3v

DIAGNOSTICS

On success, putc(), fputc(), and putchar() return the value that was written. On error, those functions return the constant EOF. putw() returns ferror(stream), so that it returns 0 on success and 1 on failure.

BUGS

Because it is implemented as a macro, putc() treats a stream argument with side effects improperly. In particular, putc(c, *f++); does not work sensibly. fputc() should be used instead.

Errors can occur long after the call to putc().

Because of possible differences in word length and byte ordering, files written using putw() are machine-dependent, and may not be read using getw() on a different processor.


index | Inhaltsverzeichniss | Kommentar

Created by unroff & hp-tools. © somebody (See intro for details). All Rights Reserved. Last modified 11/5/97