.TH fprintf() "" "" "STDIO Function (libc)"
.PC "Print formatted output into file stream"
.B "#include <stdio.h>"
\fBint fprintf(\fIfp, format, \fB[\fIarg1, .\^.\^.\^. argN\^\fB])\fR
\fBFILE *\fIfp\^\fB; char *\fIformat\^\fB;\fR
\fB[\fIdata type\^\fB] \fIarg1, .\^.\^. argN\^\fB;\fR
.PP
.II "stream^print formatted text"
.II "text^print formatted into stream"
.II "print formatted text into stream"
.B fprintf()
formats and prints a string.
It resembles the function
.BR printf() ,
except that it writes its output into the stream pointed to by
.IR fp ,
instead of to the standard output.
.PP
.B fprintf()
uses the
.I format
to specify an output format for
.I arg1
through
.IR argN .
.PP
See
.B printf()
for a description of
.BR fprintf() 's
formatting codes.
.PP
If it wrote the formatted string correctly,
.B fprintf()
returns the number of characters written.
Otherwise, it returns a negative number.
.SH Example
For an example of this routine, see the entry for
.BR fscanf() .
.SH "See Also"
.Xr "libc," libc
.Xr "printf()," printf
.Xr "sprintf()," sprintf
.Xr "vfprintf()" vfprintf
.br
\*(AS, \(sc7.9.6.1
.br
\*(PX Standard, \(sc8.1
.SH Notes
Because C does not perform type checking,
it is essential that an argument match its specification.
For example, if the argument is a
.B long
and the specification
is for a
.BR short ,
.B fprintf()
will peel off the first word of that
.B long
and present it as an
.BR short .
