# C Token Review
In C programming, tokens are the smallest individual elements that make up a program. Here's a comprehensive review of C tokens:
## 1. Keywords
These are reserved words with special meaning to the compiler:
```c
auto break case char const continue
default do double else enum extern
float for goto if int long
register return short signed sizeof static
struct switch typedef union unsigned void
volatile while _Bool _Complex _Imaginary
```
## 2. Identifiers
Names given to variables, functions, arrays, etc.:
- Rules:
- Must begin with letter or underscore
- Can contain letters, digits, underscores
- Case-sensitive
- Cannot be a keyword
## 3. Constants/Literals
Fixed values that don't change:
- Integer: `123`, `-456`, `0x1A` (hex), `0123` (octal)
- Floating-point: `3.14`, `-0.5e-10`
- Character: `'a'`, `'\n'`, `'\x41'`
- String: `"Hello"`, `"Line 1\nLine 2"`
## 4. Operators
Symbols that perform operations:
- Arithmetic: `+`, `-`, `*`, `/`, `%`, `++`, `--`
- Relational: `==`, `!=`, `>`, `<`, `>=`, `<=`
- Logical: `&&`, `||`, `!`
- Bitwise: `&`, `|`, `^`, `~`, `<<`, `>>`
- Assignment: `=`, `+=`, `-=`, etc.
- Miscellaneous: `sizeof()`, `&` (address), `*` (pointer), `?:` (ternary)
## 5. Special Symbols
- Brackets: `[]` (arrays), `{}` (blocks), `()` (functions)
- Punctuation: `,`, `;`, `:`, `#` (preprocessor)
## 6. Comments
Not technically tokens (removed during preprocessing), but important:
```c
// Single-line comment
/* Multi-line
comment */
```
## Token Examples
```c
#include // '#' and '' are tokens
int main() { // 'int', 'main', '(', ')', '{' are tokens
int x = 10; // 'int', 'x', '=', '10', ';' are tokens
printf("%d", x);// 'printf', '(', '"%d"', ',', 'x', ')', ';'
return 0; // 'return', '0', ';'
} // '}' is a token
```
Understanding these tokens is fundamental to writing and reading C code effectively.