Quiz Entry - updated: 2026.07.14
How are strings represented in C?
A C string is an array of ASCII bytes ending in a null byte (\0) that marks where it stops.
String "01234" in memory:
| Index | 0 | 1 | 2 | 3 | 4 | 5 |
|---|---|---|---|---|---|---|
| Char | '0' | '1' | '2' | '3' | '4' | '\0' |
| Hex | 0x30 | 0x31 | 0x32 | 0x33 | 0x34 | 0x00 |
Key facts:
- ASCII digit N has value
0x30 + N(e.g., '5' = 0x35) - Strings are byte-order independent (always sequential)
- Null terminator (
\0) marks the end
Go deeper:
Null-terminated string (Wikipedia) — the C string convention and its trade-offs.
ASCII (Wikipedia) — the character-to-byte code table behind C strings.