Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ putc(S) — Xenix 2.3.4

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

fclose(S)

ferror(S)

fopen(S)

fread(S)

getc(S)

printf(S)

puts(S)

PUTC(S)



     PUTC(S)                  XENIX System V                   PUTC(S)



     Name
          putc, putchar, fputc, putw - Puts a character or word on a
          stream.

     Syntax
          #include <stdio.h>

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

          int putchar (c)
          int c;

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

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

     Description
          putc appends the character c to the named output 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 ).

          fputc behaves like putc, but is a genuine function rather
          than a macro; it may therefore be used as an argument.
          fputc runs more slowly than putc, but takes less space per
          invocation.

          putw appends the word (i.e., integer) w to the output
          stream.  putw 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(S).  The standard stream stderr is by
          default unbuffered unconditionally, but use of freopen (see
          fopen(S)) causes it to become buffered or line-buffered;
          setbuf(S), again, sets 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.  See fflush in fclose(S).

     See Also
          fclose(S), ferror(S), fopen(S), fread(S), getc(S),
          printf(S), puts(S)



     Page 1                                           (printed 8/7/87)





     PUTC(S)                  XENIX System V                   PUTC(S)



     Diagnostics
          When a character or word is successfully put on a stream,
          these functions each return the value they have written.
          These functions return the constant EOF upon error.  This
          will occur if the file stream is not open for writing or if
          the output file cannot be grown.  Because EOF is a valid
          integer, ferror(S) should be used to detect putw errors.

     Notes
          The stream argument with side effects is not treated
          correctly, because putc is implemented as a macro.  In
          particular,

                             putc (c, *f++);

          does not work sensibly.  fputc should be used instead.

          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.



































     Page 2                                           (printed 8/7/87)



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