Strings — Working with Text

← Course home · ← Arrays module · Unit 11/16 · Syllabus

You’ve handled text at the edges — getline, the mixing trap, one string method in a challenge. This unit puts text at the centre: the two ways C++ holds it, the std::string toolkit in full, and character-by-character processing — the foundation for every analyzer, validator, and parser to come.

In this module you will learn

Module map

Page What’s inside
Lesson 1 — Two ways to hold text chars, character arrays, std::string, creation, input, getline
Lesson 2 — Measuring, indexing, joining, comparing length, indexing + traversal, concatenation, comparison
Lesson 3 — Finding, cutting, changing find + npos, substr, insert/erase/replace, <cctype> processing
Lesson 4 — Conversions and mistakes string↔number conversion, the common mistakes gallery
Exercises 26 exercises with separated solutions (S1–S26)
Debugging 10 seeded string bugs
Predictions 10 output/trace problems, answers separated
Challenges 10 challenges with separated solutions
Labs 7 text labs, each with solution + explanation
Mini-project The Text Analysis Toolkit

Try it yourself first

Same rule as every module: attempt 15 minutes before opening any solution. Strings add one habit to the pre-code routine: write out the boxes — a string is a row of chars with a length, and drawing "cat" as c·a·t with indices 0, 1, 2 turns most off-by-one and boundary bugs into things you can see.

Pacing

Unit 11 spans one week (2 sessions):

What comes next

The Files module applies this entire toolkit to files — reading and writing lines is getline at scale. And the password/validator labs here are the direct ancestors of input-handling in every later project.

Checklist