466
|
1 <refentry id="fread">
|
|
2 <refnamediv>
|
570
|
3 <refname>Fread</refname>
|
|
4 <refname>Fwrite</refname>
|
|
5 <refpurpose>read/write binary data</refpurpose>
|
466
|
6 </refnamediv>
|
|
7
|
|
8 <refsynopsisdiv>
|
|
9 <funcsynopsis>
|
468
|
10 <funcsynopsisinfo>
|
|
11 #include <stdio.h>
|
|
12 </funcsynopsisinfo>
|
466
|
13 <funcprototype>
|
|
14 <funcdef><function>fread</function></funcdef>
|
570
|
15 <paramdef>char *<parameter>ptr</parameter></paramdef>
|
|
16 <paramdef>int <parameter>size</parameter></paramdef>
|
|
17 <paramdef>int <parameter>number</parameter></paramdef>
|
|
18 <paramdef>FILE *<parameter>fp</parameter></paramdef>
|
|
19 </funcprototype>
|
|
20
|
|
21 <funcprototype>
|
|
22 <funcdef><function>fwrite</function></funcdef>
|
|
23 <paramdef>char *<parameter>ptr</parameter></paramdef>
|
|
24 <paramdef>int <parameter>size</parameter></paramdef>
|
|
25 <paramdef>int <parameter>number</parameter></paramdef>
|
|
26 <paramdef>FILE *<parameter>fp</parameter></paramdef>
|
466
|
27 </funcprototype>
|
|
28 </funcsynopsis>
|
|
29
|
|
30 </refsynopsisdiv>
|
|
31
|
|
32 <refsect1><title>Description</title>
|
|
33 <para>
|
595
|
34 Fread reads from the file pointed to by "fp". "Number" is the
|
|
35 number of items of size "size" that are to be read starting at
|
|
36 "ptr". The best way to pass the argument "size" to fread is by
|
|
37 using "sizeof". Fread returns the number of items actually
|
|
38 read.
|
|
39 </para>
|
|
40 <para>
|
|
41 Fwrite writes to the file pointed to by "fp". "Number" is the
|
|
42 number of items of size "size" reading the from memory
|
|
43 starting at "ptr".
|
466
|
44 </para>
|
|
45 </refsect1>
|
552
|
46 <refsect1><title>Diagnostics</title>
|
|
47 <para>
|
655
|
48 Both functions return 0 (NULL) at the end of file or error.
|
552
|
49 </para>
|
|
50 </refsect1>
|
542
|
51
|
|
52 <refsect1><title>See Also</title>
|
|
53 <para>
|
|
54 System calls
|
|
55 <link linkend="read">read()</link>,
|
|
56 <link linkend="write">write()</link>.
|
|
57 <link linkend="fopen">Fopen()</link>,
|
|
58 <link linkend="getc">getc()</link>,
|
|
59 <link linkend="putc">putc()</link>,
|
595
|
60 <link linkend="printf">printf()</link>.
|
542
|
61 </para>
|
|
62 </refsect1>
|
|
63
|
466
|
64 </refentry>
|