Originally Posted by
the bassinvader
Hey people!!!
Bit of a simple question for you all but it might solve a few
porblems for me.
basially, i want to know if the '\n' character is put into the buffer
everytime i press enter after a 'scanf' or 'fgets' .etc
And if this is the case do i need to leave two extra characters to
house the resulting '\n' and '\0' characters?
From manpages:
Code:
s Matches a sequence of non-white-space characters; the next
pointer must be a pointer to character array that is long enough
to hold the input sequence and the terminating null character
(’\0’), which is added automatically. The input string stops at
white space or at the maximum field width, whichever occurs
first.
Fgets
Code:
fgets() reads in at most one less than size characters from stream and
stores them into the buffer pointed to by s. Reading stops after an
EOF or a newline. If a newline is read, it is stored into the buffer.
A ’\0’ is stored after the last character in the buffer.