C: Reading file with a starting point

Posted by Shinka on Stack Overflow See other posts from Stack Overflow or by Shinka
Published on 2010-05-31T16:46:56Z Indexed on 2010/05/31 16:53 UTC
Read the original article Hit count: 176

Filed under:
|

A simple question but I can't find the answer in my book. I want to read a binary file to seed a random number generator, but I don't want to seed my generator with the same seed each time I call the function, so I will need to keep a variable for my position in the file (not a problem) and I would need to know how to read a file starting a specific point in the file (no idea how). The code:

void rng_init(RNG* rng) {
  // ...

  FILE *input = fopen("random.bin", "rb");
  unsigned int seed[32];
  fread(seed, sizeof(unsigned int), 32, input);

  // seed 'rng'...

  fclose(input);
}

© Stack Overflow or respective owner

Related posts about c

    Related posts about file-io