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

NAME

6       fwrite - binary output
7

SYNOPSIS

9       #include <stdio.h>
10
11       size_t fwrite(const void *restrict ptr, size_t size, size_t nitems,
12              FILE *restrict stream);
13
14

DESCRIPTION

16       The fwrite() function shall write, from the array pointed to by ptr, up
17       to nitems elements whose size is  specified  by  size,  to  the  stream
18       pointed to by stream.  For each object, size calls shall be made to the
19       fputc() function, taking  the  values  (in  order)  from  an  array  of
20       unsigned  char exactly overlaying the object. The file-position indica‐
21       tor for the stream (if defined) shall be  advanced  by  the  number  of
22       bytes  successfully written. If an error occurs, the resulting value of
23       the file-position indicator for the stream is unspecified.
24
25       The st_ctime and st_mtime fields of the file shall be marked for update
26       between  the  successful  execution of fwrite() and the next successful
27       completion of a call to fflush() or fclose() on the same stream,  or  a
28       call to exit() or abort().
29

RETURN VALUE

31       The  fwrite() function shall return the number of elements successfully
32       written, which may be less than nitems if a write error is encountered.
33       If  size  or  nitems is 0, fwrite() shall return 0 and the state of the
34       stream remains unchanged. Otherwise, if a write error occurs, the error
35       indicator  for  the  stream  shall be set,    and errno shall be set to
36       indicate the error.
37

ERRORS

39       Refer to fputc() .
40
41       The following sections are informative.
42

EXAMPLES

44       None.
45

APPLICATION USAGE

47       Because of possible differences in element length  and  byte  ordering,
48       files  written  using  fwrite() are application-dependent, and possibly
49       cannot be read using fread() by a different application or by the  same
50       application on a different processor.
51

RATIONALE

53       None.
54

FUTURE DIRECTIONS

56       None.
57

SEE ALSO

59       ferror()  ,  fopen()  , printf() , putc() , puts() , write() , the Base
60       Definitions volume of IEEE Std 1003.1-2001, <stdio.h>
61
63       Portions of this text are reprinted and reproduced in  electronic  form
64       from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
65       -- Portable Operating System Interface (POSIX),  The  Open  Group  Base
66       Specifications  Issue  6,  Copyright  (C) 2001-2003 by the Institute of
67       Electrical and Electronics Engineers, Inc and The Open  Group.  In  the
68       event of any discrepancy between this version and the original IEEE and
69       The Open Group Standard, the original IEEE and The Open Group  Standard
70       is  the  referee document. The original Standard can be obtained online
71       at http://www.opengroup.org/unix/online.html .
72
73
74
75IEEE/The Open Group                  2003                            FWRITE(P)
Impressum