Arrays With Characters
A word with 4 characters ['M', 'O', 'N', 'A']
in a character array can be represented as follows:

You see, each character gets a place in each index.
Does this seem oddly familiar? There’s a more convenient datatype to work around characters-- the notion of a String
.
A String
lets you store a sequence of characters:

While String
s are not exactly Array
s with characters, they are similar. The primary difference is usually that String
s only contain ASCII characters terminated with a NULL (0)
character, and are of variable length.
When implementing String
s in a programming language, we'd enclose the characters in quotation marks. Some examples include “This is a String”, “Apples”, and even “78429”.
Note that this "78429"
will be treated as a collection of characters and not numbers. This means you can't compare it with integers (say 5000), and you also can't perform numeric operations on this value. If you want to work around numbers and perform operations, use an array instead.
Access all course materials today
The rest of this tutorial's contents are only available for premium members. Please explore your options at the link below.