I understand that I only need seed a random number generator once to get a good set of random numbers.
Actually I want to keep seeding the random number generator with the same seed because I want the use the same set of random numbers generated as data to test different sets of functions I have written and compare their results. As the programme will run for a long time for each function, it is preferable that I actually run them at different times using the same data.
Thanks for all the help . Finally managed to get what I want .
Sample working code as follows in case anybody wants to do a similar thing in future.
Code:void appendfile(unsigned number) { FILE *cfPtr; if ((cfPtr= fopen("c:\\updx","wb"))== NULL ) printf ("File could not be opened\n"); else{ fwrite(&number, sizeof(number), 1, cfPtr); } fclose(cfPtr); } unsigned readfile( char *string) { FILE *cfPtr; unsigned number; if ((cfPtr= fopen(string,"rb"))== NULL ) printf ("File could not be opened\n"); else{ fread(&number,sizeof(number),1,cfPtr); } fclose(cfPtr); return number; }




Reply With Quote