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>Chapter
7: Input and Output
</title>
10 <link href=
"sx9f.html" rev=precedes
>
11 <link href=
"sx10a.html" rel=precedes
>
12 <link href=
"top.html" rev=subdocument
>
15 <H1>Chapter
7: Input and Output
</H1>
18 </p><p>By ``Input and output facilities are
19 not part of the C language itself,''
21 mean that things like
<TT>printf
</TT> are just
22 function calls like any other.
24 no built-in input or output statements.
26 the implications of this
27 fact--that I/O is not built in--is
28 mainly that the compiler may not do as much checking
29 as we might like it to.
30 If we accidentally write
31 <pre> double d =
1.23;
33 </pre>the compiler says,
34 ``Hmm, a function named
<TT>printf
</TT>
35 is being called with a string and a
<TT>double
</TT>.
38 (and, in general, could not even if it wanted to)
39 notice that the
<TT>%d
</TT> format requires an
<TT>int
</TT>.
40 </p><p>Although the title of this chapter is ``Input and Output,''
41 it appears that we'll also be meeting
42 a few other routines from the standard library.
43 </p><p>If you start to do any serious programming on a particular system,
44 you'll undoubtedly discover that it has a number of more
45 specialized input/output
46 (and other system-related) routines available,
47 which promise better performance or nicer functionality
49 the pedestrian routines of C's standard library.
50 You should resist the temptation to use these nonstandard routines.
51 Because the standard library routines are defined precisely and
52 ``exist in compatible form on any system where C exists,''
53 there are some real advantages to using them.
55 when you need to do something
56 which C's standard library routines don't provide,
58 to your machine's system-specific routines right away,
59 as they may be your only choice.
60 One common example is when
61 you'd like to read one character immediately,
62 without waiting for the RETURN key.
63 How you do that depends on what system you're using;
64 it is not defined by C.)
65 </p><p><a href=
"sx10a.html" rel=subdocument
>section
7.1: Standard Input and Output
</a></p>
66 <p><a href=
"sx10b.html" rel=subdocument
>section
7.2: Formatted Output--Printf
</a></p>
67 <p><a href=
"sx10c.html" rel=subdocument
>section
7.3: Variable-length Argument Lists
</a></p>
68 <p><a href=
"sx10d.html" rel=subdocument
>section
7.4: Formatted Input--Scanf
</a></p>
69 <p><a href=
"sx10e.html" rel=subdocument
>section
7.5: File Access
</a></p>
70 <p><a href=
"sx10f.html" rel=subdocument
>section
7.6: Error Handling--Stderr and Exit
</a></p>
71 <p><a href=
"sx10g.html" rel=subdocument
>section
7.7: Line Input and Output
</a></p>
72 <p><a href=
"sx10h.html" rel=subdocument
>section
7.8.1: String Operations
</a></p>
73 <p><a href=
"sx10i.html" rel=subdocument
>section
7.8.2: Character Class Testing and Conversion
</a></p>
74 <p><a href=
"sx10j.html" rel=subdocument
>section
7.8.3: Ungetc
</a></p>
75 <p><a href=
"sx10k.html" rel=subdocument
>section
7.8.4: Command Execution
</a></p>
76 <p><a href=
"sx10l.html" rel=subdocument
>section
7.8.5: Storage Management
</a></p>
77 <p><a href=
"sx10m.html" rel=subdocument
>section
7.8.6: Mathematical Functions
</a></p>
78 <p><a href=
"sx10n.html" rel=subdocument
>section
7.8.7: Random Number Generation
</a></p>
82 <a href=
"sx9f.html" rev=precedes
>prev
</a>
83 <a href=
"sx10a.html" rel=precedes
>next
</a>
84 <a href=
"top.html" rev=subdocument
>up
</a>
85 <a href=
"top.html">top
</a>
88 This page by
<a href=
"http://www.eskimo.com/~scs/">Steve Summit
</a>
89 //
<a href=
"copyright.html">Copyright
</a> 1995,
1996
90 //
<a href=
"mailto:scs@eskimo.com">mail feedback
</a>