> This doesn't work reliably because the arguments are wrong. It's "fread(buf, size_of_item, number_of_items, file_ptr)".
No it isn't. What C standard library are you using? Above code is correct in my C standard library ... man fread:
SYNOPSIS
#include <stdio.h>
size_t fread(void *ptr, size_t size, size_t nmemb, FILE *stream);
....
The function fread() reads nmemb items of data, each size bytes long, from the stream pointed to by stream, storing them at the location given by ptr.
No it isn't. What C standard library are you using? Above code is correct in my C standard library ... man fread: