Click here to Skip to main content
15,867,141 members
Please Sign up or sign in to vote.
3.40/5 (2 votes)
See more:
How to generate a random number? I am developing the screen capture project, I want to take the screen shots in the random interval of time. So need a random variable which can choose a random number from 1 to 20?? help me..
Posted
Comments
RaviRanjanKr 30-May-11 7:39am    
Try Google.. :)

Try this,
srand( (unsigned)time( NULL ) );
int nRand = rand() % 20;


This code will generate random number below 20;
 
Share this answer
 
Use the rand[^] function - a simple Google would have found it for you!
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900