26E. Summary

A null-terminated string is an array of characters that uses a null character, '\0', as an end marker. Since an array is a pointer, a null-terminated string is a pointer, of type char*.

String constants, such as "goat", are null-terminated strings that are stored in read-only memory. A string constant has type const char*.

The length of "goat", strlen("goat"), is 4. It does not count the null character at the end of "goat". That means that "goat" occupies 5 bytes of memory.

Function strcmp compares strings for alphabetical ordering, using the ASCII order of characters. If r = strcmp(A, B), then r < 0 if A < B, r = 0 if A = B and r > 0 if A > B.

Statement

  strcpy(A, B);
copies null-terminated string B into array A, starting at the beginning of A. Statement
  strcat(A, B);
assumes that array A already holds a null-terminated string and that it has extra room after the null character. It copies null-terminated string B into array A starting at the null character in A. For example,
  char A[18];
  strcpy(A, "George");
  strcat(A, " ");
  strcat(A, "Washington");
ends with A holding "George Washington". Since strlen("George Washington") = 17, A needs 18 bytes to hold it.

Do not use the results returned by strcpy or strcat. Doing that is a frequent source of errors, and violates the coding standards.