


PUTC(3S)             STANDARD I/O FUNCTIONS              PUTC(3S)



NAME
     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  _s_t_r_e_a_m  (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  _s_t_r_e_a_m  (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 termi-
     nal.  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.



Sun Release 4.1   Last change: 10 October 1987                  1






PUTC(3S)             STANDARD I/O FUNCTIONS              PUTC(3S)



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 con-
     stant  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 _s_t_r_e_a_m
     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 ord-
     ering, files written using putw() are machine-dependent, and
     may not be read using getw() on a different processor.


































Sun Release 4.1   Last change: 10 October 1987                  2



