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
11

NAME

13       fwrite — binary output
14

SYNOPSIS

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

DESCRIPTION

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

RETURN VALUE

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

ERRORS

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

EXAMPLES

55       None.
56

APPLICATION USAGE

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

RATIONALE

64       None.
65

FUTURE DIRECTIONS

67       None.
68

SEE ALSO

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