1 <!DOCTYPE HTML PUBLIC
"-//W3O//DTD W3 HTML 2.0//EN">
2 <!-- This collection of hypertext pages is Copyright 1995, 1996 by Steve Summit. -->
3 <!-- This material may be freely redistributed and used -->
4 <!-- but may not be republished or sold without permission. -->
7 <link rev=
"owner" href=
"mailto:scs@eskimo.com">
8 <link rev=
"made" href=
"mailto:scs@eskimo.com">
9 <title>section
7.8.3: Ungetc
</title>
10 <link href=
"sx10i.html" rev=precedes
>
11 <link href=
"sx10k.html" rel=precedes
>
12 <link href=
"sx10.html" rev=subdocument
>
15 <H2>section
7.8.3: Ungetc
</H2>
17 <p>There's not much more to say about
<TT>ungetc
</TT>,
18 but two more stdio functions which
21 <TT>fread
</TT> and
<TT>fwrite
</TT>.
22 </p><p><TT>getc
</TT> and
<TT>putc
</TT>
23 (and
<TT>getchar
</TT> and
<TT>putchar
</TT>)
24 allow you to read and write a character at a time,
26 <TT>fgets
</TT> and
<TT>fputs
</TT> read and write a line at a time.
27 The
<TT>printf
</TT> family of routines does formatted output,
28 and the
<TT>scanf
</TT> family does formatted input.
29 But what if you want to read or write a big block of
30 unformatted characters, not necessarily one line long?
31 You could use
<TT>getc
</TT> or
<TT>putc
</TT> in a loop,
32 but another solution is to use
33 the
<TT>fread
</TT> and
<TT>fwrite
</TT> functions,
35 (briefly) described in appendix B1.5 on page
247.
39 <a href=
"sx10i.html" rev=precedes
>prev
</a>
40 <a href=
"sx10k.html" rel=precedes
>next
</a>
41 <a href=
"sx10.html" rev=subdocument
>up
</a>
42 <a href=
"top.html">top
</a>
45 This page by
<a href=
"http://www.eskimo.com/~scs/">Steve Summit
</a>
46 //
<a href=
"copyright.html">Copyright
</a> 1995,
1996
47 //
<a href=
"mailto:scs@eskimo.com">mail feedback
</a>