* better
[mascara-docs.git] / lang / C / the.ansi.c.programming.language / notes.accompany.ansi.c / sx4a.html
blobc1194462d6bac97ec579999f653a30092933c275
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. -->
5 <html>
6 <head>
7 <link rev="owner" href="mailto:scs@eskimo.com">
8 <link rev="made" href="mailto:scs@eskimo.com">
9 <title>section 1.1: Getting Started</title>
10 <link href="sx4.html" rev=precedes>
11 <link href="sx4b.html" rel=precedes>
12 <link href="sx4.html" rev=subdocument>
13 </head>
14 <body>
15 <H2>section 1.1: Getting Started</H2>
17 <p>page 6
18 </p><p>Deep sentence:
19 <blockquote>With these mechanical details mastered,
20 everything else is comparatively easy.
21 </blockquote>The claim that a program as simple as ``hello, world''
22 is a big hurdle
23 may seem outrageous,
24 but it's really quite true.
25 It <em>is</em> a hurdle:
26 on an unfamiliar computer,
27 it can be arbitrarily difficult to figure out how to enter a
28 text file containing program source,
29 or how to compile and link it,
30 or how to invoke it,
31 or what happened after (if?) it ran.
32 The most experienced C programmers immediately go back to this
33 one, simple program whenever they're trying out a new system
34 or a new way of entering or building programs
35 or a new way of printing output from within programs.
36 As they say,
37 everything else <em>is</em> comparatively easy.
38 </p><p>One hurdle which the authors don't mention but which many of
39 you may find yourself facing is the choice of an appropriate
40 compiler.
41 On many Unix machines, the <TT>cc</TT> command which the authors
42 describe is an older compiler which does not recognize modern,
43 ANSI Standard C syntax.
44 An old compiler will accept the simple program on page 6,
45 but it will not accept many of the other programs in the book.
46 If you find yourself getting baffling compilation errors on
47 programs which you've typed in exactly as they're shown in the
48 book, it probably indicates that you're using an older compiler.
49 On many machines, another compiler called
50 <TT>acc</TT> or
51 <TT>gcc</TT> is available,
52 and you'll want to use it, instead.
53 </p><p>Deep sentence:
54 <blockquote><TT>main</TT> will usually call other functions to help perform its job,
55 some that you wrote,
56 and others from libraries that are provided for you.
57 </blockquote>We heard about this already in the Introduction,
58 but here it is again:
59 as far as the compiler and the language definition are concerned,
60 there's no difference between a function that you write
61 and a function someone else wrote for you,
62 including a function like <TT>printf</TT>
63 which seems to be part of the language.
64 There's nothing magic about <TT>printf</TT>;
65 there's nothing that it can do that one of your functions couldn't.
66 (Well,
67 actually,
68 there are a few magic,
69 or at least surprising,
70 things about <TT>printf</TT>,
71 but they're magic in ways that your functions can be, too.)
72 </p><p>There is one slight problem with the simple ``hello, world''
73 program
74 in the book.
75 The problem
76 will usually be ignored
77 (that is, the program will usually work correctly),
78 but if you receive any warning or error messages
79 or have any problems having to do with
80 the ``value returned from <TT>main</TT>,''
81 jump forward to page 26
82 to learn why <TT>main</TT> ought to end with the line
83 <pre> return 0;
84 </pre></p><hr>
85 <p>
86 Read sequentially:
87 <a href="sx4.html" rev=precedes>prev</a>
88 <a href="sx4b.html" rel=precedes>next</a>
89 <a href="sx4.html" rev=subdocument>up</a>
90 <a href="top.html">top</a>
91 </p>
92 <p>
93 This page by <a href="http://www.eskimo.com/~scs/">Steve Summit</a>
94 // <a href="copyright.html">Copyright</a> 1995, 1996
95 // <a href="mailto:scs@eskimo.com">mail feedback</a>
96 </p>
97 </body>
98 </html>