String
More actions
A string in programming generally represents text formatted with a specific character set.
Syntax
Most programming languages indicate strings using double quotes " surrounding the string. For example:
"this is a string" "this is also a string" "4.321"
Representation
String are represented differently across different programming languages, but they are usually made up of an array or list of chars. The size and values of these char elements depends on the character set the programming language uses.
Null-termination
Languages like C do not store the length of an array. Instead, data types like strings are ended whenever a null terminator is reached. This is usually the \0 character.
Other languages with proper array types instead store strings as lists or other dynamic arrays. They store both a size and capacity.
String types
Languages like Rust have many different string types for different use-cases.
See Rust string for more info.
String methods
There are various methods you can call on strings. These include (but are not limited to):
Examples of strings
"pineapple" "3.1415926535898" "Paris, France" "01382 482659"
Non-examples of strings
3.1415926535898 true 57 'A'