Null-terminated string: Difference between revisions

Content deleted Content added
m robot Adding: es:C string
Minor reworking and reorganization, removed POV
Line 1:
{{dablink|This article is on strings in computer programming. A number of [[stringed instrument]]s, including the [[viola]] and [[cello]], have a string that, when played open, produces the [[note|note C]]. This is usually referred to as the '''C string'''.}}
 
In computing, a '''C stringsstring''' areis a [[character string|character sequence]]s stored as a one-dimensional [[character (computing)|character]] [[array]]s and terminated with a [[null character]] ('\0', called NUL in [[ASCII]]). The name refers to the ubiquitous [[C (programming language)|C programming language]] usingwhich uses this [[string (computer science)#Representations|string representation]], and is used elsewhere to distinguish this often-used representation from others.
 
In the [[C++]] [[programming language]], C strings are used in addition to another representation of character sequences, the <code>std::string</code> container found in the [[Standard Template Library]] (STL). Thus, it is important to differentiate between the traditional "C strings" and the more advancedsophisticated "string" objects provided by the STL.
The null-termination characteristic has historically created [[computer insecurity|security problems]] related to the length of the string. If the null character is not added 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. This problem can (and should) be prevented by appropriate error checking.
 
The null-termination characteristic has historically created [[computer insecurity|security problems]] related to the length of the string. If the null character is not added 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. This problem can (and should) be prevented by appropriate error checking.
In the [[C++]] [[programming language]], C strings are used in addition to another representation of character sequences, the <code>std::string</code> container found in the [[Standard Template Library]] (STL). Thus, it is important to differentiate between the traditional "C strings" and the more advanced "string" objects provided by the STL.
 
== Trivia ==