Specifying Variables

As we mentioned in Chapter 1, “Anatomy of a C Program,” you must declare every variable in a C program by stating the variable's name and type. Variable names are governed by the following rules, which also apply to other user-defined names such as function names:

C is case-sensitive. For example, myvar, MyVar, and MYVAR are different names.

The name can't be a keyword (see online help for a list of keywords).

The first character must be a letter or underscore ( _ ). Many of QuickC's system-defined names, including some library-routine names, begin with underscores. To avoid conflicts with such names, don't create names that begin with underscores.

Other characters can be letters, digits, or underscores.

The first 31 characters of local variable names are significant. The name can contain more than 31 characters, but QuickC ignores everything beyond the thirty-first character. Global variable names are normally significant to 30 characters.

All C keywords are lowercase, and it's common to use lowercase for variable names. Mixed case is becoming popular in some contexts, however. Windows and OS/2 use mixed case for most system-defined names.