String

From Higher Computing Science
Jump to: navigation, search

This article is unfinished. Please consider joining and adding to this article. Read about Page layout beforehand.

Key points

  • A string is an array of characters. Most languages treat strings differently from arrays, because text is commonly used and manipulated in a program.

Information

A string is a complex data type. A string holds a series of characters. In many programming languages, a string is an array of characters.

Strings are used in programs to label values, store text input and provide information.

Storing strings

As with any data, strings are stored as 0s and 1s. This is achieved by representing each character as a number, using a code such as ASCII or Unicode.

Concatenation and substring

Strings can be concatenated (joined together) or substrings can be produced (parts of a string).

In the example below, parts of each string entered are taken. At the end of the program, all the parts of the strings are concatenated together to form a single string.

Videos

Further information

Test yourself

Teaching resources