Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training,
learning paths, books, tutorials, and more.

Using Character Arrays

All of the examples in this chapter have used numeric arrays, but arrays can also store characters (which, yes, are technically integers). By creating an array of characters, you can create a string. This concept was introduced back in Chapter 2 but merits a review.

There are two important differences between character arrays and other array types. First, storing a string in a character array always requires an extra element. This extra, final element stores the terminating NULL character (\0), which marks the end of a string. Table 6.2 lists the elements for a character array called name with a value of Aubrey.

Table 6.2. A string stored in a character array is actually multiple individual characters terminated by the ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training,
learning paths, books, interactive tutorials, and more.