Still having trouble generating random seeds. Here's my code:
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
double dev_random_seed(){
double randval;
FILE* f;
f = fopen("/dev/random", "r");
if(f == NULL){
fprintf(stderr, "WARNING: Failed to open /dev/random. Random seed defaults to 1. \n");
return 1;
}
fread(&randval, sizeof(double), 1, f);
fclose(f);
return randval;
}
int main(int argc, char** argv){
double arse = dev_random_seed();
printf("errno: %i\n",errno);
}
The output of which is:
errno: 22
which is EINVAL. Can't spot the mistake , I suck at c.