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>2.4 Variable Names
</title>
10 <link href=
"sx2c.html" rev=precedes
>
11 <link href=
"sx2e.html" rel=precedes
>
12 <link href=
"sx2.html" rev=subdocument
>
15 <H2>2.4 Variable Names
</H2>
17 <p>[This section corresponds to K
&R Sec.
2.1]
18 </p><p>Within limits, you can give your variables
22 (the formal term is ``identifiers'')
23 consist of letters, numbers, and underscores.
24 For our purposes, names must begin with a letter.
26 names can be as long as you want,
27 but extremely long ones get tedious to type after a while,
28 and the compiler is not required to keep track of extremely
30 (What this means is that if you were to name a variable, say,
31 <TT>supercalafragalisticespialidocious
</TT>,
32 the compiler might get lazy and pretend that you'd named it
33 <TT>supercalafragalisticespialidocio
</TT>,
34 such that if you later misspelled it
35 <TT>supercalafragalisticespialidociouz
</TT>,
36 the compiler wouldn't catch your mistake.
37 Nor would the compiler necessarily be able to tell the
38 difference if for some perverse reason you
<em>deliberately
</em>
39 declared a second variable named
40 <TT>supercalafragalisticespialidociouz
</TT>.)
42 </p><p>The capitalization of names in C is significant:
43 the variable names
<TT>variable
</TT>,
<TT>Variable
</TT>, and
45 (as well as silly combinations like
<TT>variAble
</TT>)
47 </p><p>A final restriction on names is that you may not use
<dfn>keywords
</dfn>
48 (the words such as
<TT>int
</TT> and
<TT>for
</TT>
49 which are part of the syntax of the language)
50 as the names of variables or functions
51 (or as identifiers of any kind).
55 <a href=
"sx2c.html" rev=precedes
>prev
</a>
56 <a href=
"sx2e.html" rel=precedes
>next
</a>
57 <a href=
"sx2.html" rev=subdocument
>up
</a>
58 <a href=
"top.html">top
</a>
61 This page by
<a href=
"http://www.eskimo.com/~scs/">Steve Summit
</a>
62 //
<a href=
"copyright.html">Copyright
</a> 1995,
1996
63 //
<a href=
"mailto:scs@eskimo.com">mail feedback
</a>