Switch to SpeakEasy.net DSL

The Modular Manual Browser

Home Page
Manual: (SunOS-4.1.3)
Apropos / Subsearch:
optional field

PUTC(3S)                                                              PUTC(3S)

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

       #include <&lt;stdio.h>&gt;

       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;

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

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

       fputc() behaves like putc(), but is a function  rather  than  a  macro.
       fputc() runs more slowly than putc(), but it takes less space per invo-
       cation 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 destina-
       tion 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 NEW-
       LINE character is written or terminal input is requested).  setbuf(3V),
       setbuffer(),  or setvbuf() may be used to change the stream's buffering

       fclose(3V), ferror(3V),  fopen(3V),  fread(3S),  getc(3V),  printf(3V),
       puts(3S), setbuf(3V),

       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 fail-

       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.

                                10 October 1987                       PUTC(3S)