Using cin.getline() to get char array

I have a short code like this to test the use of cin.getline(). I declared a char array consisting of 4 elements. However, when I enter four characters and press enter, only the first 3 characters were read. Why is it?

PHOTO: http://s28.postimg.org/4luw96071/Untitled.png
One character is needed to store the null character (\0), which indicates the end of the string
Because you need a spare character for "endline" symbol.
Topic archived. No new replies allowed.