Skip to content

Arrays and strings

Strings

Lessons on this topic

Intermediate · 25 minYou are hereRead

Strings in C

A C string is an array of chars ending in a zero byte. Every string function walks until it finds that zero, so a buffer too small for a copy goes wrong without a word.

Intermediate · 20 minYou are hereRead

Working with strings

Most string tasks are a walk with one or two pointers. Letters are numbers, so changing case is a subtraction, and reversing or testing a palindrome needs no second array.

Intermediate · 20 minYou are hereRead

Counting and bitmasks

A table of 26 counts, or the 26 bits of one integer, records which letters have been seen, so repeats and anagrams are found in one pass over the string.

Intermediate · 25 minYou are hereRead

Permutations

Every ordering of a string comes from fixing each letter in the first place in turn and ordering the rest the same way, swapping back after each try.

Phasorium

Account

Sign inWith Google, GitHub or your email

Subjects

Site

Look