S
santosh
Hi,
A book that I'm currently using notes that the fgets() function does
not
return until Return is pressed or an EOF or other error is encountered.
It then at most (in the absence of EOF/error), returns n-1 characters
plus
a appended null character.
Now, my question is:
If during a call to fgets(), (say with n == 64 and stdin), the user
happens
to enter much more than 64 characters, say 128, 256 or something like
that, fgets() would return with first 63 characters and a appended null
character only when the user presses Enter.
What would happen to the other characters? Can I assume that they would
be saved in a libc or OS level buffer and if so, upto what extent?
If fgets() blocks until Enter is pressed, am I correct in the
assumption that
successive calls to fgets() to retrieve the remaining characters would
fail,
since Enter is pressed by the user only once?
I'm confused as to the behaviour fgets() would exhibit under the above
conditions. None of the books or Standard Library documentation seem to
mention it.
Thanks.
A book that I'm currently using notes that the fgets() function does
not
return until Return is pressed or an EOF or other error is encountered.
It then at most (in the absence of EOF/error), returns n-1 characters
plus
a appended null character.
Now, my question is:
If during a call to fgets(), (say with n == 64 and stdin), the user
happens
to enter much more than 64 characters, say 128, 256 or something like
that, fgets() would return with first 63 characters and a appended null
character only when the user presses Enter.
What would happen to the other characters? Can I assume that they would
be saved in a libc or OS level buffer and if so, upto what extent?
If fgets() blocks until Enter is pressed, am I correct in the
assumption that
successive calls to fgets() to retrieve the remaining characters would
fail,
since Enter is pressed by the user only once?
I'm confused as to the behaviour fgets() would exhibit under the above
conditions. None of the books or Standard Library documentation seem to
mention it.
Thanks.