Null-terminated string

In computer programming, a null-terminated string is a character string stored as an array containing the characters and terminated with a null character (a character with an internal value of zero, called "NUL" in this article, not same as the glyph zero). Alternative names are C string, which refers to the C programming language and ASCIIZ[1] (although C can use encodings other than ASCII).

The length of a string is found by searching for the (first) NUL. This can be slow as it takes O(n) (linear time) with respect to the string length. It also means that a string cannot contain a NUL (there is a NUL in memory, but it is after the last character, not in the string).

  1. ^ "Chapter 15 - MIPS Assembly Language" (PDF). Carleton University. Retrieved 9 October 2023.