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.7: Line Input and Output
</title>
10 <link href=
"sx10f.html" rev=precedes
>
11 <link href=
"sx10h.html" rel=precedes
>
12 <link href=
"sx10.html" rev=subdocument
>
15 <H2>section
7.7: Line Input and Output
</H2>
19 <TT>puts
</TT> is like
<TT>fputs
</TT>
20 except that the stream is assumed to be the standard output (
<TT>stdout
</TT>),
21 <em>and
</em> a newline (
<TT>'\n'
</TT>) is automatically appended.
22 <TT>gets
</TT> is like
<TT>fgets
</TT>
23 except that the stream is assumed to be
<TT>stdin
</TT>,
24 and the newline (
<TT>'\n'
</TT>) is deleted,
25 <em>and
</em> there's no way to specify the maximum line length.
26 This last fact means that
32 since you can't tell it how big the array it's to read into is,
33 there's no way to guarantee
34 that some unexpectedly-long input line
35 won't overflow the array,
37 (When discussing the drawbacks of
<TT>gets
</TT>,
38 it's customary to point out that the ``Internet worm,''
39 a program that wreaked havoc in
1988
40 by breaking into computers all over the net,
43 because a key network utility
47 the worm was able to overflow the buffer
48 in a particularly low, cunning way,
49 with the dire result that
50 the worm achieved superuser access to the attacked machine.)
54 <a href=
"sx10f.html" rev=precedes
>prev
</a>
55 <a href=
"sx10h.html" rel=precedes
>next
</a>
56 <a href=
"sx10.html" rev=subdocument
>up
</a>
57 <a href=
"top.html">top
</a>
60 This page by
<a href=
"http://www.eskimo.com/~scs/">Steve Summit
</a>
61 //
<a href=
"copyright.html">Copyright
</a> 1995,
1996
62 //
<a href=
"mailto:scs@eskimo.com">mail feedback
</a>