How to use random() in C [duplicate]

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.

Leave a Comment