- What is a character set in C programming
- What alphabets are supported in C
- What digits are supported in C
- What special symbols are available
- What whitespace characters are used
- What is ASCII and how it works
What is a Character Set?
A character set is the key component behind displaying, manipulating, and editing text, numbers, and symbols on a computer. Think of it as the alphabet of the computer world.
Every C program contains statements, and these statements are made up of words. These words, in turn, are made up of characters from the C character set.
The C language supports a total of 256 characters. These are divided into several categories:
- Alphabets — A to Z and a to z
- Digits — 0 to 9
- Special Symbols — ~, @, #, $, %, ^, &, *, (, ), _, -, +, =, {, }, [, ], ;, :, ', ", /, ?, ., >, , <, \, |, etc.
- Whitespace — Space, tab, newline, etc.
💡 Key Point: Computers understand characters through ASCII codes. Each character is assigned a unique numeric value.
1. Alphabets in C
C supports all the alphabets from the English language. Lowercase and uppercase letters together make 52 alphabets.
Lowercase letters: 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
Uppercase letters: 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
2. Digits in C
C supports 10 digits which are used to construct numerical values:
0, 1, 2, 3, 4, 5, 6, 7, 8, 9
3. Special Symbols in C
C supports a rich set of special symbols that include symbols for mathematical operations, conditions, and other special purposes.
Additional special characters include:
- Whitespace — space, tab, newline
- Backspace — \b
- Vertical tab — \v
- Null — \0
- Bell — \a
4. Whitespace Characters
Whitespace characters are used to separate tokens and format code. There's no single symbol for whitespace — it's actually a set of characters:
horizontal tab — '\t'
newline — '\n'
vertical tab — '\v'
form feed — '\f'
carriage return — '\r'
You can use the isspace() function from the ctype.h library to check if a character is a whitespace character.
5. ASCII Table
ASCII stands for American Standard Code for Information Interchange. It's the standard character encoding used in computers and telecommunications.
The code was first published as a standard in 1967 and has been updated several times since. It's a 7-bit code, which means it can represent up to 128 characters.
ASCII codes are divided into three categories:
1. ASCII control characters (0-31 and 127) — Non-printable characters used for device control.
2. ASCII printable characters (32-126) — Most commonly used characters, including letters, digits, and symbols.
3. Extended ASCII characters (128-255) — Additional characters for special purposes.
Common ASCII values:
| Character | ASCII Value | Character | ASCII Value |
|---|---|---|---|
| Space | 32 | A | 65 |
| 0 | 48 | a | 97 |
| 1 | 49 | b | 98 |
| 2 | 50 | c | 99 |
| 3 | 51 | z | 122 |
| 4 | 52 | Z | 90 |
| 5 | 53 | ! | 33 |
| 6 | 54 | @ | 64 |
| 7 | 55 | # | 35 |
| 8 | 56 | $ | 36 |
| 9 | 57 | % | 37 |
Frequently Asked Questions About C Character Set
1. How many characters does C support?
C supports a total of 256 characters using the extended ASCII set.
2. What is the difference between ASCII and a character set?
ASCII is the encoding standard that assigns numbers to characters. A character set is the collection of characters that a language supports. C uses the ASCII character set.
3. What are special symbols in C?
Special symbols include punctuation marks, mathematical operators, and other characters like ~, @, #, $, %, ^, &, *, (, ), _, +, =, {, }, [, ], ;, :, ', ", /, ?, etc.
4. What is whitespace in C?
Whitespace includes spaces, tabs (\t), newlines (\n), vertical tabs (\v), form feeds (\f), and carriage returns (\r).
💡 Quick tip: Understanding character sets and ASCII codes is essential for text processing and understanding how computers store data.