#include<stdio.h>
#include<stdlib.h>
int main()
{
int *buffer;
int i;
FILE *fp;
buffer=(int *)malloc(256);
fp=fopen("BACKING_STORE.bin", "r"); //BACKING_STORE.bin is a binary file of size 65K bytes
fseek(fp, 0, SEEK_SET); //and I am trying to read 256 bytes at a time and storing
fread(buffer, 256, 1, fp); //it into buffer of size 256 bytes and printing that buffer
printf("Data=%d\n", buffer); //on screen.
fclose(fp);
}
When I run this program, I get garbage values in result. I know this because in the fseek() function I change offset. Like first when I take offset as 0 it gives me some value let's say 12342539 then I change offset to 256 it gives me output as 14562342 and again when I set offset to 0 it gives me a different output 15623478. So this is how it is showing output which is garbage.