hi everyone,
can anyone of u tell me how to generate a random number without using any c library function like rand().
the number generated should be between 0-99 only.
reply as soon as possible.
thank you
sk_agarwals
hi everyone,
can anyone of u tell me how to generate a random number without using any c library function like rand().
the number generated should be between 0-99 only.
reply as soon as possible.
thank you
sk_agarwals
If you only need a random number every couple of seconds or so, you could try using the milliseconds returned from the ftime function. Use the remainder after dividing by 100 to keep it within the range desired.
clu82Code:#include <stdio.h> #include <sys/timeb.h> int main(int argc, char* argv[]) { struct _timeb tstruct; _ftime( &tstruct ); printf( "milliseconds: %u\n", tstruct.millitm % 100); return 0; }
hi clu82,
your program is not working it is giving 2 errors so please correct it.
i am using a dos base turboc++ compiler keep this in mind.
thank you.
siddharth
siddharth,
Copy the error messages you are getting, into this thread. I am using VC++ 6.0 on Win2000. Look in your documentation to see if you have the _ftime() function and the _timeb structure. Is your compiler even finding the sys/timeb.h file?
If your compiler doesn't have the above items, it should have something similar.
clu82