> i am trying to program a function that registers what card i have drawn
So why not use an array in memory rather than a file?
Or is this an exercise in using a file as an array?
Quicky tutorial
Code:
// your array, of MYTYPE, which is NUM elements long
MYTYPE array[NUM];
// open a file in binary mode
FILE *fp = fopen( "array_on_disk", "r+b");
// write the whole array
fwrite( array, sizeof(MYTYPE), NUM, fp );
// position at array[pos]
fseek( fp, pos * sizeof(MYTYPE), SEEK_SET );
// read array[pos] from the file
fread( &array[pos], sizeof(MYTYPE), 1, fp );