- If you intend the character array be used as a string, you must append a NULL character.
- Also, notice that the size of the array has been declared to be 1 larger to include the NULL character:
char word[8] = {'C','e','l','s','i','u','s','\0'};
or
char word[8] = {'C','e','l','s','i','u','s',0};
In memory, this looks something like this:
word (refers to the entire array)
¯
word[0] ® C
word[1] ® e
word[2] ® l
word[3] ® s
word[4] ® i
word[5] ® u
word[6] ® s
word[7] ® \0 NULL character
Now, if you output this string using cout, you would end up with the correct output.