[Dev-C++] Problems (?) with rand/srand
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: <and...@su...> - 2007-11-26 13:19:31
|
Dear Users,
I´m working with srand/rand functions
to generate random values.
I have three functions that call rand()
and these functions are defined inside a
.cpp file that belongs to a project.
The file with main(), that calls these
three functions, is another file that also
belongs to this project. The calls are made
inside a fast loop.
The first attempt to generate pure random
numbers was using srand((unsigned) time(&t))
at in the file with main(). t is a variable
of type time_t. I got the same sequence of
results, that is, rand() did behave as no
previous srand() was called.
The second attempt to generate pure random
numbers was using srand((unsigned) time(&t))
inside the three functions at the first time
the functions were called. The results obtained
presented the following behaviour:
a) running directly: the same results;
b) debuging step-by-step (with time intervals
greater than 1 second): I got the expected
results. I credit this to variable t, which
could get different arguments.
My question is:
If my attempts were correct, in the point of view
of achieve my goal, does anybody know how can I
solve this? :-)))
Regards
Andre
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.5.503 / Virus Database: 269.16.7/1151 - Release Date: 25/11/2007
16:24
|