str/char 101 question

Hi
I read a program which has a char array : char str[80]. The user is supposed to input a string which can be less than 80 char. After that use gets(str) to read the string.

My question is 1. does gets(str) refill all the char in "str" or just up to the length of the input? 2. If I use cout<<str, does it print out all 80 chars (including the empty chars?)
I believe it reads as much as it wants; until the user enters a '\n' character. I assume that the array is null-terminated; if so, cout should print up until NUL character. Otherwise, it'll probably print until it finds one or the program crashes because its reading data it's not allowed to.
Topic archived. No new replies allowed.