| ??? 12/25/03 21:25 Read: times |
#61389 - P.S Responding to: ???'s previous message |
Shouldn't there be a variable to pass to the rand function to give me number of bits ie rand(4).
Here is the info supplied about the rand function in the manual: <pre> RAND Synopsis #include <stdlib.h> int rand (void) Description The rand() function is a pseudo-random number generator. It returns an integer in the range 0 to 32767, which changes in a pseudo-random fashion on each call. The algorithm will produce a deterministic sequence if started from the same point. The starting point is set using the srand() call. The example shows use of the time() function to generate a different starting point for the sequence each time. Example #include <stdlib.h> #include <stdio.h> #include <time.h> void main (void) { time_t toc; int i; time(&toc); srand((int)toc); for(i = 0 ; i != 10 ; i++) printf("%dt", rand()); putchar(ānā); } See Also srand() Note The example will require the user to provide the time() routine as one cannot be supplied with the compiler. See time() for more detail.<pre/> |



