View Full Version : Help with randomizing code.
Feb 19, 2009, 05:22 PM
I'm trying to create an app that includes a lot of randomizing. Unfortunatly, the only access I have to a sample code that deal with randomizing is in this one example where when I try to take the randomizing part out of it and put it in my own code, it doesn't want to work. I've changed it, morphed it, combined it, and nothing happens. Can someone please help me. I need just the randomizing code itself (not mixed in with a whole other code as well...).
Feb 19, 2009, 07:54 PM
What do you mean, you just need random numbers?
Feb 19, 2009, 08:03 PM
There are quite a few people on the board willing to help. Just post the code you are working on and tell us what you expect it to do. And also what it is actually doing. And if you're getting errors on compilation or when running it, make sure you copy/paste the exact error.
If you do that, I'm sure someone will help.
Feb 19, 2009, 10:43 PM
The simplest way to get a random number between 0 and 10 is
int myNum = random() % (10 + 1);
It's really a C question, not an iPhone question. If you need something more complex, read this:
use random() not rand() , though.