Mail Archives: djgpp/2004/12/18/19:07:14
> Apparently we are seeing that using fread() and reading a size that
> exceeds the end_of_file, causes ZERO elements to be returned; this
> does not seem to be what most people are expecting:
Please post your test program. Mine works fine:
#include <stdio.h>
char buf[1024];
main()
{
int rv;
FILE *f = fopen("afile.bin", "rb");
rv = fread (buf, sizeof(char), 128, f);
printf("ask 128 got %d\n", rv);
rv = fread (buf, sizeof(char), 64, f);
printf("ask 64 got %d\n", rv);
rv = fread (buf, sizeof(char), 128, f);
printf("ask 128 got %d\n", rv);
fclose(f);
exit(0);
}
C:\TMP> dj
ask 128 got 128
ask 64 got 64
ask 128 got 64
C:\TMP>
- Raw text -