LOGBOOK

HELP

Quiz Entry - updated: 2026.07.14

How are strings represented in C?

A string is just a char array (ASCII-encoded) whose end is marked by a \0 null byte — there's no separate string type or stored length.

Hello as bytes with a null terminator

* "Hello" is five characters plus a \0 terminator — 6 bytes, with no separately stored length. *

// Actually 6 bytes: H e l l o \0
char str[] = "Hello";

In memory:

Index 0 1 2 3 4 5
Char 'H' 'e' 'l' 'l' 'o' '\0'
Hex 0x48 0x65 0x6C 0x6C 0x6F 0x00

The null terminator \0:

  • Marks the end of the string
  • ASCII value 0 (not the character '0' which is 0x30)
  • Functions like strlen() count until they hit \0

Escape sequences:

Escape Meaning
\n Newline
\t Tab
\" Double quote
\\ Backslash
\0 Null character

Safe string handling:

char str[128];
// Prevents overflow
snprintf(str, sizeof(str), "%d arguments\n", argc);
// NOT sprintf(str, ...) which can overflow!

Go deeper:

From Quiz: REVE1 / C Programming | Updated: Jul 14, 2026