Batch random number through C executable
Posted: 20 Jul 2021 01:49
Hello!
I've read that batch %RANDOM% is not very random.
I thought it would be nice to have a .exe written in C programming language, which will return random number upon execution.
I've downloaded and installed Code::Blocks and tried different examples from the web, but all of them aren't producing anything good, they are using srand(time(NULL)); and rand();.
I've read that you need to create your own random number generator with example:
#define random(value) ((int)(((double)(rand())*(value))/(RAND_MAX+1.0)))
I can't figure how it works.
Can you, please, show me a C code which will generate random numbers?
Many thanks!
I've read that batch %RANDOM% is not very random.
I thought it would be nice to have a .exe written in C programming language, which will return random number upon execution.
I've downloaded and installed Code::Blocks and tried different examples from the web, but all of them aren't producing anything good, they are using srand(time(NULL)); and rand();.
I've read that you need to create your own random number generator with example:
#define random(value) ((int)(((double)(rand())*(value))/(RAND_MAX+1.0)))
I can't figure how it works.
Can you, please, show me a C code which will generate random numbers?
Many thanks!