Ch 10 · Strings · C
Topic 10 of 13 in C — Complete Tutorial (Beginner) — 2 lessons.
Strings are Char Arrays
C has no dedicated string type — a string is simply an array of char ending with a special invisible character '\0' (the null terminator) that marks where the text stops. You can create one easily with double quotes, and C adds the '\0' for you. You print strings with %s. Understanding that a string is just a char array (with a \0 at the end) is fundamental to C.
String Functions
Because strings are just char arrays, common operations live in the <string.h> library. strlen gives the length (not counting '\0'), strcpy copies one string into another, strcat joins them, and strcmp compares two strings (returning 0 when they are equal). You must include <string.h> to use these.