Foundations — String handling — char arrays, null terminator, strcpy, strcat, strlen, sprintf (dangers)
Before you can read strlen, strcpy, or sprintf in the parent note, every tiny symbol on those lines must first mean something. This page builds each one from absolute zero, in the order they lean on each other.
1. A char — one box that holds one small number
The letter 'A' is not really stored as a shape. It is stored as the number . The quotes in
'A' are C's way of saying "give me the ASCII number for this letter" so you don't have to memorise
that 'A' is .

Reveal check:
'0' (the digit) versus '\0' (the terminator) — same or different?
'0' is the number 48, '\0' is the number 0.2. An array — many boxes in a row, side by side
The number in s[i] is the index — how many boxes to walk from the start. It begins at : the
first box is s[0], not s[1]. So a 6-box array has valid indices s[0] through s[5] — the last
index is always size minus one.

Reveal check:
In char s[6], what is the highest legal index?
s[5] (size − 1).3. The null terminator '\0' — the STOP box
A row of boxes has no built-in sign telling you where the word stops. So C plants a STOP box right after the last real letter. Every string function's job is: walk forward until you meet the STOP.

Reveal check:
Why can't a program tell where a string ends without '\0'?
char boxes stores no length; the '\0' is the only end marker.4. "..." versus '...' — a whole word versus one letter
So "Hi" silently occupies 3 boxes even though you typed 2 letters. This hidden extra box is the
+1 you keep hearing about.
Reveal check:
How many boxes does the literal "cat" need?
'\0'.5. A pointer char * — an address, not the boxes themselves
Crucially, a pointer holds only the starting address. It does not remember how many boxes follow.
That is exactly why C needs the '\0' — the pointer alone can't tell you where to stop. Deep dive:
Pointers in C.
Reveal check:
Does a char * remember how many characters follow its address?
'\0' marks the end instead.6. size_t and the counter i, n — indices that never go negative
Reveal check:
Why use size_t and not int for a length?
size_t is the unsigned counting type.7. !=, =, and the while loop — the "walk until STOP" engine
The parent's core line is while (s[n] != '\0') n++; — read it as: "while the box I'm looking at is
not the STOP box, count it and step to the next." This is the shape of every string routine.
Reveal check:
What is the difference between = and !=?
= stores a value; != asks "are these unequal?".8. — "cost grows with the length"
This is why calling strlen (or strcat, which secretly scans to find the end) inside a loop can
become slow: each call re-walks the whole row.
Reveal check:
Why is strlen and not instant?
'\0' — that is steps.9. Buffer overflow — writing into a box you don't own
The classic cause is forgetting the STOP box's +1: char buf[5]; strcpy(buf, "Hello"); needs 6
boxes into 5.
Reveal check:
What happens in C if you write one box past an array's end?
How these foundations feed the topic
Equipment checklist
Do you already have each piece? Reveal only after you answer aloud.
A char really stores what?
The first element of char s[6] is written how, and the last?
s[0] first, s[5] last (index = size − 1).What is '\0' and its numeric value?
char holding the number .How many boxes does "cat" occupy?
'\0'.Difference between '0' and '\0'?
'0' is (a digit); '\0' is (the terminator).What does a char * store, and what does it NOT store?
Why can sizeof buf be wrong?
buf is a pointer, sizeof gives pointer size, not the buffer's size.Read while (s[n] != '\0') n++; in plain words.
Why is strlen ?
'\0'.