nightly: remove unused BINARCHIVE
[unleashed.git] / share / man / man3c / fwrite.3c
blob0027f2a426b2f5671a9959170f94f4837982a51b
1 .\"
2 .\" Sun Microsystems, Inc. gratefully acknowledges The Open Group for
3 .\" permission to reproduce portions of its copyrighted documentation.
4 .\" Original documentation from The Open Group can be obtained online at
5 .\" http://www.opengroup.org/bookstore/.
6 .\"
7 .\" The Institute of Electrical and Electronics Engineers and The Open
8 .\" Group, have given us permission to reprint portions of their
9 .\" documentation.
10 .\"
11 .\" In the following statement, the phrase ``this text'' refers to portions
12 .\" of the system documentation.
13 .\"
14 .\" Portions of this text are reprinted and reproduced in electronic form
15 .\" in the SunOS Reference Manual, from IEEE Std 1003.1, 2004 Edition,
16 .\" Standard for Information Technology -- Portable Operating System
17 .\" Interface (POSIX), The Open Group Base Specifications Issue 6,
18 .\" Copyright (C) 2001-2004 by the Institute of Electrical and Electronics
19 .\" Engineers, Inc and The Open Group.  In the event of any discrepancy
20 .\" between these versions and the original IEEE and The Open Group
21 .\" Standard, the original IEEE and The Open Group Standard is the referee
22 .\" document.  The original Standard can be obtained online at
23 .\" http://www.opengroup.org/unix/online.html.
24 .\"
25 .\" This notice shall appear on any product containing this material.
26 .\"
27 .\" The contents of this file are subject to the terms of the
28 .\" Common Development and Distribution License (the "License").
29 .\" You may not use this file except in compliance with the License.
30 .\"
31 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
32 .\" or http://www.opensolaris.org/os/licensing.
33 .\" See the License for the specific language governing permissions
34 .\" and limitations under the License.
35 .\"
36 .\" When distributing Covered Code, include this CDDL HEADER in each
37 .\" file and include the License file at usr/src/OPENSOLARIS.LICENSE.
38 .\" If applicable, add the following below this CDDL HEADER, with the
39 .\" fields enclosed by brackets "[]" replaced with your own identifying
40 .\" information: Portions Copyright [yyyy] [name of copyright owner]
41 .\"
42 .\"
43 .\" Copyright 1989 AT&T
44 .\" Copyright (c) 1997, The Open Group. All Rights Reserved.
45 .\" Portions Copyright (c) 2002, Sun Microsystems, Inc.  All Rights Reserved.
46 .\"
47 .TH FWRITE 3C "Jul 24, 2002"
48 .SH NAME
49 fwrite \- binary output
50 .SH SYNOPSIS
51 .LP
52 .nf
53 #include <stdio.h>
55 \fBsize_t\fR \fBfwrite\fR(\fBconst void *\fR\fIptr\fR, \fBsize_t\fR \fIsize\fR, \fBsize_t\fR \fInitems\fR, \fBFILE *\fR\fIstream\fR);
56 .fi
58 .SH DESCRIPTION
59 .sp
60 .LP
61 The \fBfwrite()\fR function writes, from the array pointed to by \fIptr\fR, up
62 to \fInitems\fR elements whose size is specified by \fIsize\fR, to the stream
63 pointed to by \fIstream\fR. For each object, \fIsize\fR calls are made to the
64 \fBfputc\fR(3C) function, taking the values (in order) from an array of
65 \fBunsigned char\fR exactly overlaying the object. The file-position indicator
66 for the stream (if defined) is advanced by the number of bytes successfully
67 written. If an error occurs, the resulting value of the file-position indicator
68 for the stream is unspecified.
69 .sp
70 .LP
71 The \fBst_ctime\fR and \fBst_mtime\fR fields of the file will be marked for
72 update between the successful execution of \fBfwrite()\fR and the next
73 successful completion of a call to \fBfflush\fR(3C) or \fBfclose\fR(3C) on the
74 same stream or a call to \fBexit\fR(2) or \fBabort\fR(3C).
75 .SH RETURN VALUES
76 .sp
77 .LP
78 The \fBfwrite()\fR function returns the number of elements successfully
79 written, which might be less than \fInitems\fR if a write error is encountered.
80 If \fIsize\fR or \fInitems\fR is 0, \fBfwrite()\fR returns 0 and the state of
81 the stream remains unchanged. Otherwise, if a write error occurs, the error
82 indicator for the stream is set and \fBerrno\fR is set to indicate the error.
83 .SH ERRORS
84 .sp
85 .LP
86 Refer to \fBfputc\fR(3C).
87 .SH USAGE
88 .sp
89 .LP
90 Because of possible differences in element length and byte ordering, files
91 written using \fBfwrite()\fR are application-dependent, and possibly cannot be
92 read using \fBfread\fR(3C) by a different application or by the same
93 application on a different processor.
94 .SH ATTRIBUTES
95 .sp
96 .LP
97 See \fBattributes\fR(5) for descriptions of the following attributes:
98 .sp
102 box;
103 c | c
104 l | l .
105 ATTRIBUTE TYPE  ATTRIBUTE VALUE
107 Interface Stability     Standard
109 MT-Level        MT-Safe
112 .SH SEE ALSO
115 \fBwrite\fR(2), \fBfclose\fR(3C), \fBferror\fR(3C), \fBfopen\fR(3C),
116 \fBfread\fR(3C), \fBgetc\fR(3C), \fBgets\fR(3C), \fBprintf\fR(3C),
117 \fBputc\fR(3C), \fBputs\fR(3C), \fBattributes\fR(5), \fBstandards\fR(5)