Generating random numbers in C

Posted by moonstruckhorrors on Stack Overflow See other posts from Stack Overflow or by moonstruckhorrors
Published on 2010-06-18T05:23:55Z Indexed on 2010/06/18 5:33 UTC
Read the original article Hit count: 259

While searching for Tutorials on generating random numbers in C I found This Topic

When I try to use the rand() function with parameters, I always get the random number generated 0. When I try to use the rand() function with parameters, I always get the value 41.

And whenever I try to use arc4random() and random() functions, I get a LNK2019 error.

Here's what I'm doing:

#include <stdlib.h>
int main()
{
int x;
x = rand(6);
printf("%d", x);
}

This code always generate 41.

Where am I going wrong??

P.S. : I'm running Windows XP SP3 and using VS2010 Command Prompt as compiler. P.P.S. : Took me 15 minutes to learn how to format properly.

© Stack Overflow or respective owner

Related posts about c

    Related posts about beginner