Module 10 · Strings
Strings: an Array That Ends in a Zero
Free with an accountReading
Bob is printing name tags for Maria's shop. He counts the letters in Maria, gets five, and makes five boxes: char name[5] = "Maria";. Beside it sits char city[6] = "Dhaka";. GCC 12 says nothing, even at -Wall -Wextra, and the Playground printed Maria's tag as [MariaDhaka]. This lesson finds the box Bob forgot, the one that holds no letter at all.
Checking what this lesson needs for you…
What is inside Strings: an Array That Ends in a Zero
- A string is a row of chars that ends at a zero
- A string literal brings its own zero
- Walking a string until the zero
- Length and capacity are two numbers
- When the zero is missing
- Copying a string box by box
- Comparing two strings box by box