'\" te .\" Copyright (c) 1997, The Open Group. All Rights Reserved. .\" Copyright 1989 AT&T .\" Portions Copyright (c) 2002, Sun Microsystems, Inc. All Rights Reserved. .\" Sun Microsystems, Inc. gratefully acknowledges The Open Group for permission to reproduce portions of its copyrighted documentation. Original documentation from The Open Group can be obtained online at http://www.opengroup.org/bookstore/. .\" The Institute of Electrical and Electronics Engineers and The Open Group, have given us permission to reprint portions of their documentation. In the following statement, the phrase "this text" refers to portions of the system documentation. Portions of this text are reprinted and reproduced in electronic form in the Sun OS Reference Manual, from IEEE Std 1003.1, 2004 Edition, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 6, Copyright (C) 2001-2004 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between these versions and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http://www.opengroup.org/unix/online.html. This notice shall appear on any product containing this material. .TH fwrite 3C "24 Jul 2002" "SunOS 5.11" "Standard C Library Functions" .SH NAME fwrite \- binary output .SH SYNOPSIS .LP .nf #include \fBsize_t\fR \fBfwrite\fR(\fBconst void *\fR\fIptr\fR, \fBsize_t\fR \fIsize\fR, \fBsize_t\fR \fInitems\fR, \fBFILE *\fR\fIstream\fR); .fi .SH DESCRIPTION .sp .LP The \fBfwrite()\fR function writes, from the array pointed to by \fIptr\fR, up to \fInitems\fR elements whose size is specified by \fIsize\fR, to the stream pointed to by \fIstream\fR. For each object, \fIsize\fR calls are made to the \fBfputc\fR(3C) function, taking the values (in order) from an array of \fBunsigned char\fR exactly overlaying the object. The file-position indicator for the stream (if defined) is advanced by the number of bytes successfully written. If an error occurs, the resulting value of the file-position indicator for the stream is unspecified. .sp .LP The \fBst_ctime\fR and \fBst_mtime\fR fields of the file will be marked for update between the successful execution of \fBfwrite()\fR and the next successful completion of a call to \fBfflush\fR(3C) or \fBfclose\fR(3C) on the same stream or a call to \fBexit\fR(2) or \fBabort\fR(3C). .SH RETURN VALUES .sp .LP The \fBfwrite()\fR function returns the number of elements successfully written, which might be less than \fInitems\fR if a write error is encountered. If \fIsize\fR or \fInitems\fR is 0, \fBfwrite()\fR returns 0 and the state of the stream remains unchanged. Otherwise, if a write error occurs, the error indicator for the stream is set and \fBerrno\fR is set to indicate the error. .SH ERRORS .sp .LP Refer to \fBfputc\fR(3C). .SH USAGE .sp .LP Because of possible differences in element length and byte ordering, files written using \fBfwrite()\fR are application-dependent, and possibly cannot be read using \fBfread\fR(3C) by a different application or by the same application on a different processor. .SH ATTRIBUTES .sp .LP See \fBattributes\fR(5) for descriptions of the following attributes: .sp .sp .TS tab() box; cw(2.75i) |cw(2.75i) lw(2.75i) |lw(2.75i) . ATTRIBUTE TYPEATTRIBUTE VALUE _ Interface StabilityCommitted _ MT-LevelMT-Safe _ StandardSee \fBstandards\fR(5). .TE .SH SEE ALSO .sp .LP \fBwrite\fR(2), \fBfclose\fR(3C), \fBferror\fR(3C), \fBfopen\fR(3C), \fBfread\fR(3C), \fBgetc\fR(3C), \fBgets\fR(3C), \fBprintf\fR(3C), \fBputc\fR(3C), \fBputs\fR(3C), \fBattributes\fR(5), \fBstandards\fR(5)