String (computer science): Difference between revisions

Content deleted Content added
History: keep hyphen
String length: keep prev. version: stop char needn't be 0x00, link to subsection here
Line 43:
 
=== String length ===
Although formal strings can have an arbitrary finite length, the length of strings in real languages is often constrained to an artificial maximum. In general, there are two types of string datatypes: ''fixed-length strings'', which have a fixed maximum length to be determined at [[compile time]] and which use the same amount of memory whether this maximum is needed or not, and ''variable-length strings'', whose length is not arbitrarily fixed and which can use varying amounts of memory depending on the actual requirements at run time (see [[Memory management]]). Most strings in modern [[programming languages]] are variable-length strings. Of course, even variable-length strings are limited in length by the amount of available memory. The string length can be stored as a separate integer (which may put another artificial limit on the length) or implicitly through a termination character, known asusually a [[null-terminatedcharacter string]]value orwith aall "Cbits string",zero namedsuch afteras thein C programming language. See also "[[C (programming language)#Null-terminated|CNull-terminated]]" below.
 
=== Character encoding ===