Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

In C, a string must contain a null-termination character by definition. This null-termination character exists at or before the address of the last element of the array containing the string. Character arrays must be null-terminated before they may be safely passed as arguments to standard string-handling functions, such as strcpy() or strlen(). These functions, as well as other string-handling functions defined by the C Standard, depend on the existence of the string's null-termination character to determine the length of the string. Likewise, character sequences must be null-terminated before iterating on the sequence where the termination condition of the loop depends on the existence of a null-termination character within the memory allocated for the sequence, as in the following example:

...