C String
For the underwear/swimwear, see Thong (clothing).
In computing, a C string is a character sequence stored as a one-dimensional character array and terminated with a null character ('\0', called NUL in ASCII). The name refers to the ubiquitous C programming language which uses this string representation.
Alternative names are ASCIIZ and Null-terminated string.
In C programs, strings are usually handled with string pointers, which hold the memory location of the first character of the string. The length of the string is not stored, and is instead calculated using strlen, which counts the number of characters, starting at the pointer's memory location, before a null character is reached.
In the C++ programming language, C strings are used in addition to another representation of character sequences, the std::string container found in the Standard Template Library (STL).
The Microsoft Foundation Class Library (MFC) provides its own string class for C++, called a CString, which internally represents the string as a C string, but does not require the programmer to handle memory allocation issues.
The null-termination characteristic has historically created security problems related to the length of the string. If the null character is not correctly accounted for, any following non-related memory area may also be 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. It may also cause a buffer overflow.
C String header
The C standard library named string.h (<cstring> header in C++) is used to work with C strings.
Confusion or programming errors arise when strings are treated as simple data types.