Guided Notes
Strings
Strings as null-terminated char arrays, string literals, string.h functions, character functions, and safe string handling.
Strings are char arrays
Slide 1 / 5C has no string type. A string is an array of chars ending with the null character '\0': char name[] = "Ada"; // 4 bytes: 'A' 'd' 'a' '\0'
• Print with %s: printf("%s\n", name); • Access characters by index: name[0] is 'A'. • The array must have room for the '\0' terminator. • Single quotes are a char ('A'); double quotes are a string ("A" — two bytes).
Functions find the end of a string by searching for '\0' — without it, they run off into other memory.
