* remove "\r" nonsense
[mascara-docs.git] / C / the.ansi.c.programming.language / c.programming.notes / sx2d.html
blob5fc5c4cd30fa3120220473e83014e9afaf6ff3d7
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>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>
13 </head>
14 <body>
15 <H2>2.4 Variable Names</H2>
17 <p>[This section corresponds to K&amp;R Sec. 2.1]
18 </p><p>Within limits, you can give your variables
19 and functions
20 any names you want.
21 These names
22 (the formal term is ``identifiers'')
23 consist of letters, numbers, and underscores.
24 For our purposes, names must begin with a letter.
25 Theoretically,
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
29 long ones perfectly.
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
44 <TT>VARIABLE</TT>
45 (as well as silly combinations like <TT>variAble</TT>)
46 are all distinct.
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).
52 </p><hr>
53 <p>
54 Read sequentially:
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>
59 </p>
60 <p>
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>
64 </p>
65 </body>
66 </html>