Strings and Character Processing

Lesson 4 of 20

Walk two pointers into a palindrome and shift every letter of zyx three steps to land on cab.

The big picture

Meet the chars

A string is a sequence of characters you can index, compare and mutate — and each character is secretly a small number.

A string is a sequence

word[0] is the first character — indexes run 0 to size() - 1, exactly like arrays.

std::string manages itself

It grows, knows its length and copies deeply. No manual memory, unlike C-style char arrays.

Characters are numbers

a is 97, b is 98 — so c - a gives 0..25, the trick behind ciphers and letter counting.

The char toolkit

isalpha, isdigit, tolower and toupper classify and reshape one character at a time.

Two-pointer walks

lo at the start, hi at the end, walking inward — the palindrome pattern below.