Quote Originally Posted by Salem View Post
> In what respect does fgets() differ from gets()?
fgets won't overrun the end of the buffer you supply, so long as you're honest about the size of the buffer.

> what is the size of the said buffer?
Whatever you want it to be.

Typically, you do this.
Code:
char buff[BUFSIZ];  // defined in stdio, with a min value of 256 (it's 4K on my machine)
while ( fgets(buff,BUFSIZ,stdin) ) {
  // do stuff
}

> I intend to create functions which input acutely voluminous tracts of texts through stdin
So your "do stuff" may include things like malloc and strcpy.
It depends whether you can analyse a line there and then, or whether you need to read some/all of the file before you can proceed.

If really long lines are possible, and that's important to you, your first step is to see if buff contains a \n.
If it doesn't, then you know you have a long line.

> For instance, I intend to input a sentence, but I wish to delete
> the newline before it gets attached to a string
Yes, fgets() will store the newline if there is room in the buffer to store it.
>fgets won't overrun the end of the buffer you supply, so long as you're honest about the size of the buffer.

In this context, the "buffer" you're referring to is the array wherein the input shall be stored, isn't it?

>Whatever you want it to be.

How does one define the buffer then? Secondly, why is it that before the input is passed to the character array, it is initially stored in environment-defined stdin buffer?