Identifiers
Each variable name is an example of an identifier. The rule for the syntax of an identifier is that is a
sequence of characters, starting with a letter or an underscore (_) and continuing with any
combination of letters, digits and underscores. In the grammar definition
language EBNF:
- identifier
- nondigit
identifier nondigit
identifier digit
-
nondigit
- a b c d e f g h i j k l m n o p q r s t u v w x y z
- A B C D E F G H I J K L M N O P Q R S T U V W X Y Z _
- digit
- 0 1 2 3 4 5 6 7 8 9
Notice that upper case and lower case letters are defined separately. They are treated as different
characters in C, so names Val1 and val1 are regarded as different. C is said to be case sensitive.
The following are valid C identifiers:
a1
henry_the_1st
_DIDI
The following are not valid:
1a (starts with a digit)
henry_#1 (contains a non-alphanumeric character other than _)
Exercises on this section.
Next.
Back to Contents page.