Random number generation

Posted by Chandan Shetty SP on Stack Overflow See other posts from Stack Overflow or by Chandan Shetty SP
Published on 2010-04-23T14:49:04Z Indexed on 2010/04/23 14:53 UTC
Read the original article Hit count: 356

I am using below code to generate random numbers in range...

int randomNumberWithinRange(int min,int max)
{
        int snowSize = 0;
        do
        {
            snowSize = rand()%max;
        }
        while( snowSize < min || snowSize > max );
        return snowSize;
    }

for(int i = 0; i < 10 ; i++)
  NSlog("@"%d",\t", randomNumberWithinRange(1,100));

If I quit my application and restart, same set of numbers are generated. How to generate different set of random numbers for every launching.

© Stack Overflow or respective owner

Related posts about iphone

Related posts about random