WeeBeng
January 28th, 2003, 11:11 PM
I would like to find a way to store an unsigned value most accurately so that I could reuse it when I seed my random number generator. Currently, I am writing it to a file. However I realise that what is stored will be dependent on the conversion specifier. Which conversion specifier will ensure the most accurate storage?
unsigned seedtime;
seedtime=(unsigned)time( NULL );// This will be the seed which I //require
appendfile(seedtime);
//code for appendfile
void appendfile( unsigned count)
{
FILE *cfPtr;
if ((cfPtr= fopen("updx.txt","a"))== NULL )
printf ("File could not be opened\n");
else{
fprintf(cfPtr,"%u\n",count);
}
fclose(cfPtr);
}
Currently I am using %u but wonder if there is any other better and more accurate coversion specifier.
Is there any other method to store my unsigned seedtime so that I can use it again when I run my program?
Another question regards my fopen command . Is there any way I can change the directory in which updx.txt can be stored? Currently it is stored in my working directory but I would like to change it to my specification.
Thanx a lot in advance for any help.
unsigned seedtime;
seedtime=(unsigned)time( NULL );// This will be the seed which I //require
appendfile(seedtime);
//code for appendfile
void appendfile( unsigned count)
{
FILE *cfPtr;
if ((cfPtr= fopen("updx.txt","a"))== NULL )
printf ("File could not be opened\n");
else{
fprintf(cfPtr,"%u\n",count);
}
fclose(cfPtr);
}
Currently I am using %u but wonder if there is any other better and more accurate coversion specifier.
Is there any other method to store my unsigned seedtime so that I can use it again when I run my program?
Another question regards my fopen command . Is there any way I can change the directory in which updx.txt can be stored? Currently it is stored in my working directory but I would like to change it to my specification.
Thanx a lot in advance for any help.