Toggle menu
Toggle preferences menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

A string in programming generally represents text formatted with a specific character set.

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

edit edit source

String are represented differently across different programming languages, but they are usually made up of an array or collection of chars. The size and values of these char elements depends on the character set the programming language uses.

Null-termination

edit edit source

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 collections. They store both a size and capacity.

Languages like Rust have many different string types for different use-cases.

See Rust string for more info.

String methods

edit edit source

There are various methods you can call on strings. These include (but are not limited to):

Examples of strings

edit edit source
"pineapple"
"3.1415926535898"
"Paris, France"
"01382 482659"

Non-examples of strings

edit edit source
3.1415926535898
true
57
'A'