On Fri, Nov 08, 2019 at 12:05:19AM +0100, Egeyar Bagcioglu wrote:
> On 11/7/19 7:57 PM, Segher Boessenkool wrote:
> >>>Opening a file as "r" but then
> >>>accessing it with "fread" is peculiar, too.
> >>I am not sure what you mean here. Is it that you prefer "wb" and "rb"
> >>instead of "w" and "r"? I thought it was enough to use a consistent pair.
> >I'd use fgets or similar, not fread.
> Two things made me prefer fread over fgets here:
> 1) Although I am reading a string, I do not need each read character to 
> be checked against newline. I just need to read till end-of-file.
> 2) fread returns the number of elements read which I later use. If I 
> used fgets, I'd need to call strlen or so afterwards to get the string size.
> Let me know please if you disagree or if there are advantages / 
> disadvantages that I omit.

Somehow I thought fread works differently with text streams than it does.
Maybe because you don't often see fread on text streams :-)

Sorry for the noise,


Reply via email to