i tried to write a function that sample 4 bytes from card.raw
file but i doesn't work because fread
doesn't put any data into block
buffer so i wrote this simple code and i found out that fgetc
works while fread
doesn't
FILE *ptr = fopen("card.raw","w+");
unsigned char *block = malloc(sizeof(unsigned char) * 512);
if (block == NULL)
{
fprintf(stderr, "couldn't allocate memory\n");
return 5;
}
fread(block, 1, 512, ptr);
unsigned char c = fgetc(ptr);
printf("*block = %i\nc = %i\n", *block ,c);
that's the output of this program
*block = 0
c = 255
and the same thing happens when i try to use array instead of using malloc any idea why is this happening ?