First, to answer your second statement (you didn't word your topic in questions):
If you take a look at the definition of getline (
http://www.cplusplus.com/reference/iostream/istream/getline/)
you will see that only n-1 characters are extracted where n is the second parameter.
the nth character is written as the null terminator ( '\0' )
So cin.getline(response, 4)
says that response is a char array with a length of four, only read 3 chars into it and write the 4th char as 0.
if you want the function to do what you intend, use the length of response:
1 2 3
|
int const size; // initialized
char response [size];
cin.getline(response, size);
|
To answer your second statement would require the intense ability to read your mind.
I have no idea what you are attempting to ask.
You said the cstrings limits can be exceeded and referenced your definition of the response array.
How does this show that the char array's (cstring's) limits are being exceeded?
If the cstring ( assuming you mean char[ ] ) does not end in 0 or the null terminator '/0', when strlen is used it will keep reading values until 0 is reached.. if that's what you mean by the cstrings limits being exceeded.
However, if you tried to write to the array past it's size you would get a runtime error.