1FWRITE(3P) POSIX Programmer's Manual FWRITE(3P)
2
3
4
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
12 fwrite - binary output
13
15 #include <stdio.h>
16
17 size_t fwrite(const void *restrict ptr, size_t size, size_t nitems,
18 FILE *restrict stream);
19
20
22 The fwrite() function shall write, from the array pointed to by ptr, up
23 to nitems elements whose size is specified by size, to the stream
24 pointed to by stream. For each object, size calls shall be made to the
25 fputc() function, taking the values (in order) from an array of
26 unsigned char exactly overlaying the object. The file-position indica‐
27 tor for the stream (if defined) shall be advanced by the number of
28 bytes successfully written. If an error occurs, the resulting value of
29 the file-position indicator for the stream is unspecified.
30
31 The st_ctime and st_mtime fields of the file shall be marked for update
32 between the successful execution of fwrite() and the next successful
33 completion of a call to fflush() or fclose() on the same stream, or a
34 call to exit() or abort().
35
37 The fwrite() function shall return the number of elements successfully
38 written, which may be less than nitems if a write error is encountered.
39 If size or nitems is 0, fwrite() shall return 0 and the state of the
40 stream remains unchanged. Otherwise, if a write error occurs, the error
41 indicator for the stream shall be set, and errno shall be set to indi‐
42 cate the error.
43
45 Refer to fputc().
46
47 The following sections are informative.
48
50 None.
51
53 Because of possible differences in element length and byte ordering,
54 files written using fwrite() are application-dependent, and possibly
55 cannot be read using fread() by a different application or by the same
56 application on a different processor.
57
59 None.
60
62 None.
63
65 ferror(), fopen(), printf(), putc(), puts(), write(), the Base Defini‐
66 tions volume of IEEE Std 1003.1-2001, <stdio.h>
67
69 Portions of this text are reprinted and reproduced in electronic form
70 from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
71 -- Portable Operating System Interface (POSIX), The Open Group Base
72 Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of
73 Electrical and Electronics Engineers, Inc and The Open Group. In the
74 event of any discrepancy between this version and the original IEEE and
75 The Open Group Standard, the original IEEE and The Open Group Standard
76 is the referee document. The original Standard can be obtained online
77 at http://www.opengroup.org/unix/online.html .
78
79
80
81IEEE/The Open Group 2003 FWRITE(3P)