• Create Account

### #ActualServant of the Lord

Posted 10 January 2013 - 09:54 PM

Sure, do this:

srand(time(0));

for(int i = 0; i < 10; i++)
{
std::cout << rand() << std::endl;
}

It's a simple sanity check: If each of the 10 values printed are identical, the problem is with rand(). If each (or most) of the 10 values are different, the problem is in your code.

Meanwhile, remove the srand() in the main loop and leave only the srand() at the start of WinMain() and post your complete code exactly as it compiles.

You might try doing a text search for your entire project to make sure that srand() is only called once.

You appear to have some functions pre-declared inside the scope of your WinMain() - is there a reason you're doing that?

### #1Servant of the Lord

Posted 10 January 2013 - 09:52 PM

Sure, do this:

srand(time(0));

for(int i = 0; i < 10; i++)
{
std::cout << rand() << std::endl;
}

It's a simple sanity check: If each of the 10 values printed are identical, the problem is with rand(). If each (or most) of the 10 values are different, the problem is in your code.

Meanwhile, remove the srand() in the main loop and leave only the srand() at the start of WinMain() and post your complete code.

You might try doing a text search for your entire project to make sure that srand() is only called once.

PARTNERS