When is the setbuf function useful (except the NULL value)?
I try to invent the examples, but I can't still.
I understand how setvbuf can be useful, but I don't understand with setbuf.
Basically, setvbuf is a newer API to the same logic as setbuf. setbuf exists for compatibility with programs that were written before setvbuf existed.
So in other words, unless you're dealing with code that already uses setbuf, just ignore that it exists.
Reference:
Function:
void setbuf (FILE *stream, char *buf)
- If
bufis a null pointer, the effect of this function is equivalent to callingsetvbufwith a mode argument of_IONBF. Otherwise, it is equivalent to callingsetvbufwithbuf, and a mode of_IOFBFand a size argument ofBUFSIZ.- The setbuf function is provided for compatibility with old code; use setvbuf in all new programs.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With