C Character Data Types

C Character Data Types (Complete Guide: Beginner → Advanced)
In C language, the character data type is used to store single characters or small numeric values (ASCII codes).
It is 1 byte in size and is extremely important for strings, input/output, and low-level programming.
What is a Character Data Type?
A character data type (
char) stores one character at a time.
- Characters are stored internally as ASCII values
Size of char
- Always 1 byte (8 bits)
ASCII Value Concept
Each character has a numeric ASCII code.
| Character | ASCII |
|---|---|
| ‘A’ | 65 |
| ‘a’ | 97 |
| ‘0’ | 48 |
| ‘ ‘ (space) | 32 |
Types of char in C
C provides three variations of character type:
char
Can be signed or unsigned (compiler dependent)
signed char
Range: −128 to 127
unsigned char
Range: 0 to 255
Example: Signed vs Unsigned char
- Very important in embedded & system programming
Character Input & Output
Input
Output
Character Arithmetic
- Because characters are stored as numbers
char vs int (Important Difference)
| Feature | char | int |
|---|---|---|
| Size | 1 byte | 4 bytes |
| Stores | Character / small number | Large number |
| ASCII usage | Yes | Indirect |
charsaves memory
char in Strings
- String = array of char
- Ends with
'\0'(null character)
Special Characters in char
char with <ctype.h> Functions
Common functions:
isalpha()isdigit()islower()toupper()tolower()
Common Mistakes
- Using double quotes
"A"instead of'A' Forgetting&inscanf()Assumingcharis always signed- Confusing
'0'and0
Interview Questions (Must Prepare)
Size of
charin C?Difference between
charandunsigned char?What is ASCII?
Output of
char c = 65; printf("%c", c);Difference between
'A'and"A"?
Real-Life Use Cases
String processing
Text files
Keyboard input
Embedded systems
Byte-level operations
Summary
charstores a single character- Always 1 byte
- Uses ASCII internally
signed&unsignedaffect range- Essential for strings, I/O & system programming
