C/C++ Arena

Step 1 of 6

The null terminator

C has no built-in string type. A string is a char array that ends with the special character '\0' (value 0), called the null terminator.

char name[] = "dust";
// stored as: 'd' 'u' 's' 't' '\0'   (5 chars!)

Functions like printf("%s") print characters until they hit '\0'. Forget it, and they keep reading random memory.

Your turn: build the string "ak" by hand and print it.

Next: strlen and friends