C Keywords & Identifiers: A Practical Guide
C Keywords & Identifiers
Discover the core C language elements – reserved keywords and how to name identifiers correctly. This concise guide is built on years of real‑world C development experience.
Character Set
A character set defines the characters that can appear in identifiers and other parts of a C program.
Alphabets
Uppercase: A B C … X Y Z Lowercase: a b c … x y z
C accepts both uppercase and lowercase letters for variable and function names.
Digits
0 1 2 3 4 5 6 7 8 9
Special Characters
| , | < | > | . | _ |
| ( | ) | ; | $ | : |
| % | [ | ] | # | ? |
| ' | & | { | } | " |
| ^ | ! | * | / | | |
| - | \ | ~ | + |
Whitespace characters include space, newline, tab, carriage return, and form feed.
C Keywords
Keywords are reserved words that the compiler recognizes and that cannot be reused as identifiers. They form the backbone of C syntax.
int money;
Here, int is a keyword indicating that money is an integer variable.
Because C is case‑sensitive, all keywords must be written in lowercase.
Below is the full list of ANSI C keywords, a reference that every C developer should master:
auto | double | int | struct |
break | else | long | switch |
case | enum | register | typedef |
char | extern | return | union |
continue | for | signed | void |
do | if | static | while |
default | goto | sizeof | volatile |
const | float | short | unsigned |
For a deeper dive into each keyword’s syntax and use cases, see List of all keywords in C programming.
C Identifiers
An identifier is the name you assign to variables, functions, structs, and other entities. Identifiers must be unique within their scope.
int money;
double accountBalance;
In the example above, money and accountBalance are identifiers.
Remember: an identifier cannot be a keyword; for example, you cannot name a variable int.
Rules for Naming Identifiers
- A valid identifier may contain letters (uppercase or lowercase), digits, and underscores.
- The first character must be a letter or an underscore.
- Keywords are forbidden as identifier names.
- Identifier length is unlimited in theory, but many compilers limit it to 31 characters. Stick to reasonable lengths for portability.
Choose descriptive names that convey intent—good naming practices improve code readability and maintainability.
C Language
- Understanding C# Keywords and Identifiers: Rules, Lists, and Best Practices
- Mastering C++ Variables, Literals, and Constants: A Comprehensive Guide
- Python Keywords and Identifiers: Mastering Reserved Words and Naming Conventions
- C Tokens, Identifiers, and Keywords: Understanding Tokens and Their Types
- Leveraging Robotics for Faster, Safer Aerospace & Defense Production
- Generative Design & Continuous 3D Fiber Deposition: AI-Driven Innovation
- Thermography Explained: How Infrared Imaging Detects Temperature Variations
- Revolutionizing Packaging: Advanced Robotics & Automation for Faster, Safer Shipments
- Navigating the Global Semiconductor Shortage: Impact and Solutions
- Carbon‑14 Dating: Unlocking Material Histories in Science & Industry