previous | start | next

## Character Arrays

- There was a time when C++ had no `string` class.
- All string processing was carried out by manipulating arrays of the type `char`.
- The char type denotes an individual character and is delimited by single quotes.

  >     char input = 'y'; /* don't confuse with "y" */

- A character array is used to hold a string.

  >     char greeting[] = "Hello";
  >        /* same as greeting[6] = "Hello"; */

- The array occupies size characters - one for each letter and a zero terminator.

  `greeting[0]` | `greeting[1]` | `greeting[2]` | `greeting[3]` | `greeting[4]` | `greeting[5]`
  `'H'` | `'e'` | `'l'` | `'l'` | `'o'` | `'\0'`

- You do not need to specify the size of the array variable for a character array constant.

previous | start | next