|
||||||
| C and C++ C and C++ forum for discussing all forms of C except for C#. These languages are powerful low level languages used for creating Operating Systems, Device Drivers, compilers and much more. |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
|
|||
|
Code:
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
int main(void) {
int a = 0;
printf("GNU GCC compiler RAND_MAX: %i \n", RAND_MAX);
time_t seed;
time(&seed);
srand((int) seed);
printf("Seed is : %i \n", seed);
for(a = 0; a < 20; a++) {
printf("rand: %0.3f \n", rand());
}
getchar();
}
|
| Sponsored Links |
|
|
|
|||
|
Also it's not necessary to do all that with time.
Just do this... Code:
srand(time(NULL)); |
![]() |
| Tags |
| gcc, mingw, rand |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Function returns nothing. | shibbythestoner | PHP Forum | 14 | 12-21-2007 04:20 PM |
| responseXML returns null | plits | AJAX | 1 | 10-30-2007 07:48 AM |
| WingedPanther | ........ | 2753.6 |
| Xav | ........ | 2704 |
| Brandon W | ........ | 1702.32 |
| John | ........ | 1207.73 |
| marwex89 | ........ | 1175.24 |
| morefood2001 | ........ | 966.05 |
| dcs | ........ | 655.75 |
| Steve.L | ........ | 475.59 |
| orjan | ........ | 418.58 |
| Aereshaa | ........ | 383.54 |