I am trying to read an empty file with fread. Before i created the file with a blocksize of 4096 and an amount of 40 blocks. At the moment I know that these Blocks are "empty" but if i read the file like in my code below I cannot tell wether it is empty or not. I mean I am expecting nread to be NULL or something like that. Do you know what I have to compare nread with? Thank you!
int test()
{
char buf[4096];
FILE *file;
size_t nread;
file = fopen("out/abc.store", "r");
if (file) {
while ((nread = fread(buf, 1, sizeof buf, file)) > 0)
fwrite(buf, 1, nread, stdout);
if (ferror(file)) {
/*error handling*/
}
fclose(file);
}
EDIT:
I created the file like that:
char *content=(char*)malloc(uintBlockSize*uintBlockCount);
memset(content,0,uintBlockSize*uintBlockCount);
...
while (i!=0)
{
check=fwrite(content,uintBlockSize, 1, storeFile);
if (check!=1)
return 1;
i--;
}