1fputc(3C)                Standard C Library Functions                fputc(3C)
2
3
4

NAME

6       fputc,  putc,  putc_unlocked,  putchar,  putchar_unlocked, putw - put a
7       byte on a stream
8

SYNOPSIS

10       #include <stdio.h>
11
12       int fputc(int c, FILE *stream);
13
14
15       int putc(int c, FILE *stream);
16
17
18       int putc_unlocked(int c, FILE *stream);
19
20
21       int putchar(int c);
22
23
24       int putchar_unlocked(int c);
25
26
27       int putw(int w, FILE *stream);
28
29

DESCRIPTION

31       The fputc() function writes the byte specified by c  (converted  to  an
32       unsigned  char) to the output stream pointed to by stream, at the posi‐
33       tion indicated by the associated file-position indicator for the stream
34       (if  defined),  and  advances  the indicator appropriately. If the file
35       cannot support positioning requests, or if the stream was  opened  with
36       append mode, the byte is appended to the output stream.
37
38
39       The  st_ctime and st_mtime fields of the file will be marked for update
40       between the successful execution of fputc()  and  the  next  successful
41       completion  of a call to fflush(3C) or fclose(3C) on the same stream or
42       a call to exit(3C) or abort(3C).
43
44
45       The putc() routine behaves like fputc(), except that it is  implemented
46       as a macro. It runs faster than fputc(), but it takes up more space per
47       invocation and its name cannot be passed as an argument to  a  function
48       call.
49
50
51       The  call  putchar(c)  is  equivalent to putc(c, stdout). The putchar()
52       routine is implemented as a macro.
53
54
55       The putc_unlocked() and putchar_unlocked()  routines  are  variants  of
56       putc() and putchar(), respectively, that do not lock the stream.  It is
57       the caller's responsibility to acquire the stream lock  before  calling
58       these routines and releasing the lock afterwards; see flockfile(3C) and
59       stdio(3C). These routines are implemented as macros.
60
61
62       The putw() function writes the word (that is, type int) w to the output
63       stream (at the position at which the file offset, if defined, is point‐
64       ing). The size of a word is the size of a  type  int  and  varies  from
65       machine  to  machine.   The  putw() function neither assumes nor causes
66       special alignment in the file.
67
68
69       The st_ctime and st_mtime fields of the file will be marked for  update
70       between the successful execution of putw() and the next successful com‐
71       pletion of a call to fflush(3C) or fclose(3C) on the same stream  or  a
72       call to exit(3C) or abort(3C).
73

RETURN VALUES

75       Upon   successful   completion,   fputc(),   putc(),   putc_unlocked(),
76       putchar(), and putchar_unlocked() return the value  that  was  written.
77       Otherwise,  these  functions  return  EOF,  the error indicator for the
78       stream is set, and errno is set to indicate the error.
79
80
81       Upon successful completion, putw() returns 0. Otherwise, it  returns  a
82       non-zero value, sets the error indicator for the associated stream, and
83       sets errno to indicate the error.