1FWRITE(3P)                 POSIX Programmer's Manual                FWRITE(3P)
2
3
4

PROLOG

6       This  manual  page is part of the POSIX Programmer's Manual.  The Linux
7       implementation of this interface may differ (consult the  corresponding
8       Linux  manual page for details of Linux behavior), or the interface may
9       not be implemented on Linux.
10

NAME

12       fwrite — binary output
13

SYNOPSIS

15       #include <stdio.h>
16
17       size_t fwrite(const void *restrict ptr, size_t size, size_t nitems,
18           FILE *restrict stream);
19

DESCRIPTION

21       The functionality described on this reference page is aligned with  the
22       ISO C  standard.  Any  conflict between the requirements described here
23       and the ISO C standard is unintentional. This  volume  of  POSIX.1‐2017
24       defers to the ISO C standard.
25
26       The fwrite() function shall write, from the array pointed to by ptr, up
27       to nitems elements whose size is  specified  by  size,  to  the  stream
28       pointed to by stream.  For each object, size calls shall be made to the
29       fputc() function, taking  the  values  (in  order)  from  an  array  of
30       unsigned  char exactly overlaying the object. The file-position indica‐
31       tor for the stream (if defined) shall be  advanced  by  the  number  of
32       bytes  successfully written. If an error occurs, the resulting value of
33       the file-position indicator for the stream is unspecified.
34
35       The last data modification and last file status  change  timestamps  of
36       the file shall be marked for update between the successful execution of
37       fwrite() and the next successful completion of a call  to  fflush()  or
38       fclose() on the same stream, or a call to exit() or abort().
39

RETURN VALUE

41       The  fwrite() function shall return the number of elements successfully
42       written, which may be less than nitems if a write error is encountered.
43       If  size  or  nitems is 0, fwrite() shall return 0 and the state of the
44       stream remains unchanged. Otherwise, if a write error occurs, the error
45       indicator  for the stream shall be set, and errno shall be set to indi‐
46       cate the error.
47

ERRORS

49       Refer to fputc().
50
51       The following sections are informative.
52

EXAMPLES

54       None.
55

APPLICATION USAGE

57       Because of possible differences in element length  and  byte  ordering,
58       files  written  using  fwrite() are application-dependent, and possibly
59       cannot be read using fread() by a different application or by the  same
60       application on a different processor.
61

RATIONALE

63       None.
64

FUTURE DIRECTIONS

66       None.
67

SEE ALSO

69       Section  2.5,  Standard  I/O  Streams,  ferror(),  fopen(),  fprintf(),
70       putc(), puts(), write()
71
72       The Base Definitions volume of POSIX.1‐2017, <stdio.h>
73
75       Portions of this text are reprinted and reproduced in  electronic  form
76       from  IEEE Std 1003.1-2017, Standard for Information Technology -- Por‐
77       table Operating System Interface (POSIX), The Open Group Base  Specifi‐
78       cations  Issue  7, 2018 Edition, Copyright (C) 2018 by the Institute of
79       Electrical and Electronics Engineers, Inc and The Open Group.   In  the
80       event of any discrepancy between this version and the original IEEE and
81       The Open Group Standard, the original IEEE and The Open Group  Standard
82       is  the  referee document. The original Standard can be obtained online
83       at http://www.opengroup.org/unix/online.html .
84
85       Any typographical or formatting errors that appear  in  this  page  are
86       most likely to have been introduced during the conversion of the source
87       files to man page format. To report such errors,  see  https://www.ker
88       nel.org/doc/man-pages/reporting_bugs.html .
89
90
91
92IEEE/The Open Group                  2017                           FWRITE(3P)
Impressum