NAME | SYNOPSIS | DESCRIPTION | RETURN VALUES | ATTRIBUTES | SEE ALSO
#include <stdio.h>int putc(int c, FILE * stream);
The putc and fputc functions writes the byte specified by c (converted to an unsigned char) to the output stream (at the position where the file pointer, if defined, is pointing).
The putw function writes the specified int to the defined output stream.
The putc routine behaves like fputc , except that it is implemented as a macro. It runs faster than fputc , but it takes up more space per invocation and its name cannot be passed as an argument to a function call.
Output streams, with the exception of the standard error stream stderr , are by default buffered if the output refers to a file and line-buffered if the output refers to a terminal. The standard error output stream stderr is by default unbuffered, but use of freopen (see fopen (3STDC)) will change it to become buffered or line-buffered. When an output stream is unbuffered, information is queued for writing on the destination file or terminal as soon as it is written. When it is buffered, a number characters are saved 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 new-line character is written or terminal input is requested). The setbuf (3STDC) or setvbuf (3STDC) function may be used to change the stream's buffering strategy.
Upon successful completion, these functions each return the value they have written. If unsuccessful, they return the constant EOF. This will occur if the file stream is not open for writing or if the output file cannot be extended.
See attributes(5) for descriptions of the following attributes:
ATTRIBUTE TYPE | ATTRIBUTE VALUE |
---|---|
Interface Stability | Evolving |
fclose(3STDC) , ferror(3STDC) , fopen(3STDC) , fread(3STDC) , printf(3STDC) , putchar(3STDC) , puts(3STDC) , setbuf(3STDC)
NAME | SYNOPSIS | DESCRIPTION | RETURN VALUES | ATTRIBUTES | SEE ALSO