At least you realize it! I have said to myself more than once, with a rather irritated voice "You IDIOT! - What were you thinking?" [I even hit the keys hard when I wrote that to make it more emphasized, can you tell?]. As programming requires a certain level of detail mindedness, it happens that we make mistakes.
I did think that the cause of problem was something along those lines. And if you search the forum for "srand call only once" or some such, I'm pretty sure you'll find at least two posts THIS MONTH, and many more if you read through more. When novice programmers hear about srand, they think "Ah, it makes the random numbers more random, so calling it more must make it even better" (or something like that), and then wondering why when you call srand a dozen times in a second with a time that only chances once a second, it gives the same random number a dozen times in a row...Instead of calling srand once in the main program of my project I was calling it repeatedly in the function called from the main program. I have corrected this stupid error and removed the sleep() line and all is well.
--
Mats