Episode #125 of the Stack Overflow podcast is here. We talk Tilde Club and mechanical keyboards. Listen now

A string is a sequence of characters. It is commonly used to represent text or a sequence of bytes. Use this tag along with the appropriate programming language being used.

A string is a sequence of characters commonly used to represent text; in most languages a string is a data type.

It is also used to represent a sequence of bytes encoding arbitrary binary data.

In the original C representation, a string is an array of characters (which are byte-sized ints) terminated by the "null character" \0. In the context of string implementations (or other programming languages), this implementation is often referred to as a C string.

In most languages, strings can be iterated over, similar to lists or arrays. However, in high-level languages (in which strings are a data type unto themselves), strings are immutable, whereas arrays are mutable.

String uses certain encoding to represent characters as bytes. Newer encodings like UTF-8 use variable number of bytes per character, making less trivial to access the next char, previous char or char at the given index in the string. A byte per char ASCII encoding uses is restricted to Latin alphabet. Some strings (like Java String) use 2 bytes per character.

For more details, see the Wikipedia entry on String.

history | excerpt history