Null-terminated string

This is an old revision of this page, as edited by 82.181.66.63 (talk) at 20:26, 3 August 2005 (fixed some markup). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

In computing, C strings are character sequences stored as one-dimensional character arrays and terminated with a null character ('\0'). The name refers to the ubiquitous C programming language using this string representation, and is used elsewhere to distinguish this often-used representation from others.

The null-termination characteristic has historically created security problems related to the length of the string. If the null character is not put to the end of the string for some reason, any following non-related memory area is also processed as a part of the character sequence. This can lead to program crashes or leakage of program internal information to attackers or non-understanding users.

In C++ programming language, C strings are used in coordination with another representation of character sequences, the STL (ANSI standard C++) strings. Thus, it is important to differentiate between "C strings" and "strings" that are objects of the STL string class.


See also