0

How do i make a randomizer in C that works

Help me to make a randomizer in C!!!

7th Sep 2018, 9:58 AM
Shreeniket Upasani
Shreeniket Upasani - avatar
5 Antworten
+ 1
you can include stdlib.h (iirc) which contains the rand() and srand() methods
7th Sep 2018, 11:18 AM
hinanawi
hinanawi - avatar
+ 1
what hinanawi means is that you need to set a random seed everytime you open a prpgram, and that can be done with time(NULL) which will be different everytime is opened.
10th Sep 2018, 9:52 AM
Bebida Roja
Bebida Roja - avatar
0
use /dev/random if on linux. no need for randomizer
7th Sep 2018, 10:03 AM
Bebida Roja
Bebida Roja - avatar
0
i tried but its giving me the same number over and over again
10th Sep 2018, 8:26 AM
Shreeniket Upasani
Shreeniket Upasani - avatar
0
Shreeniket Upasani that's because you have to do srand(time(NULL)) every time you want a new number generated (time.h should be included also)
10th Sep 2018, 8:30 AM
hinanawi
hinanawi - avatar