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.
Get C Programming: Visual Quickstart Guide now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.