fread return value?

Andy Valencia dont at spam.me
Thu Jul 31 00:53:44 UTC 2025


On Wednesday, 30 July 2025 at 20:03:37 UTC, 0xEAB wrote:
> On Wednesday, 30 July 2025 at 19:45:20 UTC, Andy Valencia wrote:
>> but I'd like to understand what's up before just changing my 
>> code to assume 0 is a success value?
>
> AFAICT your code is wrong.
> The parameters of `fread()` are `ptr`, `size`, `n`, `stream`.
> Your code is attempting to read `1` unit with a size of 
> `buf.length`. If the stream has less then a single unit of size 
> `buf.length` left, it has obviously read 0 units. Which it 
> reports.

(Looks at manual.  Looks at code.  SMH.)

Thanks.  I've been writing C code since K&R, but I guess it _has_ 
been a while.  Sorry to bug you for such a dumb one!

Andy



More information about the Digitalmars-d-learn mailing list