Created: 2023-01-11 10:55
Status: #concept
Subject: Programming
Tags: C Variable
Identifier
Naming Rules
in C and Python
Their syntax is similar to Python where the first character has to be a letter or underscore or
$
, NOT a number.
It accepts all characters except special characters other than underscore after the first letter.
C is case-sensitive when it comes to identifiers: sum != Sum
.
DON’T USE UNDERSCORES AS STARTING CHARACTERS - it’s bad programming practice outside Python class methods.
Legal Identifiers
int times10, get_next_char, _done;
Illegal Identifiers
int 10times, get-next-char, super%;
/* will cause compiler error: "stray <special char> in program" */
References
- C Programming, A Modern Approach, 2nd Edition, Chapter 2.7