#include <stdio.h>
int main(int argc, char **argv)
{
FILE *f;
int n;
f = fopen("d:\\data.bin", "rb");
if (!f)
{
printf("Unable to open d:\\data.bin");
return 1;
}
// SEEK_SET - offset is relative to the beginning of the file
fseek(f, sizeof(int) * 2, SEEK_SET);
fread(&n, sizeof(int), 1, f);
printf("%d\n", n);
fseek(f, sizeof(int) * 5, SEEK_SET);
fread(&n, sizeof(int), 1, f);
printf("%d\n", n);
fclose(f);
return(0);
}
/*
(in file we have the numbers: 1 2 3 4 5 6 7 8 9 10)
run:
3
6
*/