Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ putc(3s) — Ultrix-11 3.1

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

fclose(3s)

fopen(3s)

fread(3s)

getc(3s)

printf(3s)

puts(3s)

putc(3s)

NAME

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

SYNTAX

#include <stdio.h>

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

putchar(c)
int c;

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

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

DESCRIPTION

The putc macro appends the character c to the named output stream.  It returns the character written. 

The putchar(c) subroutine is defined as putc(c, stdout). 

The fputc behaves like putc, but is a genuine function rather than a macro.  It may be used to save on object text. 

The putw subroutine appends word (that is, int) w to the output stream.  It returns the word written.  The putw subroutine neither assumes nor causes special alignment in the file. 

The standard stream stdout is normally buffered if and only if the output does not refer to a terminal.  This default may be changed by setbuf(3s).  The standard stream stderr is by default unbuffered unconditionally, but use of freopen will cause it to become buffered.  For further information, see fopen(3s).  The setbuf, again, will set the state to whatever is desired.  When an output stream is unbuffered information appears on the destination file or terminal as soon as written.  When it is buffered many characters are saved up and written as a block.  The fflush subroutine may be used to force the block out early.  For further information, see fclose(3s). 

RESTRICTIONS

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

DIAGNOSTICS

These functions return the constant EOF upon error.  Since this is a good integer, ferror(3s) should be used to detect putw errors. 

SEE ALSO

fclose(3s), fopen(3s), fread(3s), getc(3s), printf(3s), puts(3s)

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026