#Random is not Random
14 messages · Page 1 of 1 (latest)
When your question is answered use !solved to mark the question as resolved.
Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question use !howto ask.
int kartenZufall()
{
int karte = 0;
srand((unsigned)time(NULL));
karte = (rand() % 13) + 2;
if (karte > 10)
{
if (karte == 14)
{
karte = 11;
}
else
{
karte = 10;
}
}
return karte;
}
Random is never purely random, you need to seed it with delta or system time
You should only srand (seed the random number) once at the beginning of the program
You're doing it at every function call here, which will keep reseeding it with the same value because I assume you call this function multiple times within a second
ok yes i need to write srand % 13
No, move the srand call to the top of main
That's what time(null) does
ok
I know?
I maybe should have been a bit more clear doing it more as once