← C Programming learning path
C Programming · Module 6 of 10

Arrays and strings

Store many values in arrays; strings are char arrays ending with \0.

📖 Key ideas

  1. int marks[5]; holds 5 ints, indexed 0 to 4.
  2. C does not check array bounds; going past the end is a serious bug.
  3. A string is a char array ending with the null character \0.
  4. string.h gives strlen, strcpy, strcmp, strcat.
  5. Use fgets (not gets) to read a line of text safely.
💡 Real-life example: An array is a row of numbered seats; a string is a word written in those seats with a full stop (\0) at the end.
ArrayFixed-size list of same-type values
\0Null character that ends a string
strlenLength of a string
strcmpCompares two strings