previous | start | next

## Character Arrays

- Many string functions in the standard library depend on zero terminators in character arrays.

  >     int strlen(const char s[])
  >     {
  >        int i = 0;
  >        while (s[i] != '\0')
  >           i++;
  >        return i;
  >     }

- It's important to not forget the space for the zero terminator.
- It's helpful to declare character arrays with an "extra space" for the zero terminator.

  >     const int MYSTRING_MAXLENGTH = 4;
  >     char mystring[MYSTRING_MAXLENGTH + 1];

previous | start | next