So I am currently learning C, and I have some confusion about how the random() function works.
I know I have to provide a seed, but I don't know how to actually generate the random number.
srandom(seed);
long int value= random(40);
When I try this it gives me a compiler error:
too many arguments to function ‘long int random()
The end goal is to get a random number between 1 and 40.
I should add that the goal is to not use the rand() function.
srand()before each call torand(). Call it once at the start of the program. I do not know why you renamed those library functions. What are they? How can we know what they do? Are they non-standard functions or your own?random()— it tells you a lot of what to do. For the rest, read Is this C implementation of Fisher-Yates shuffle correct? to see how to generate an unbiassed random number in the range 0..N (for 1..40, you'll use a random number in the range 0..39 and add 1).