String: a type of data which represents text

A common type of data used in programing, strings represent text characters, which can include spaces and numbers. Simple phrases, words, and strings of numbers and symbols are all strings.

For example, “I like hamburgers.” is a string. Counting them is a little trickier and requires some math.

Each character requires one byte of space to represent- remember, binary digits, bits, can only be a 1 or 0, so the combination of eight is what defines characters.

Therefore, to figure out how many bytes a string takes up, one must take all numbers, letters, spaces, symbols, etc. in the phrase and add them up.

In this case, there are fifteen letters, two spaces, and one period in the phrase, which totals 18 characters, or 18 bytes and18×8 =144 bits .

When actually using strings in programming, however, certain practices must be followed. For example, simply putting in the correct information for “I like hamburgers.” and entering it wouldn’t work… the computer may likely believe it is a variable name or a number.

In order for the computer to recognize it, it must be entered in quotations. Now what about separating strings from each other? That is where null characters come into play.

Null characters are bytes made of all zeros, thus carrying the total weight of zero and having no action, character, etc. associated with it.

These null characters represent the end of strings, as they carry no information, and have been used in the past to aid in printing and even in the days of punch cards.

Read more