How to make a random spawn generator

i'm using SDL engine to make a game... and i need to know how to make my characters spawn using a random spawn function with in a certain radius.... if anyone could give me some ideas... it would be appreciated
1
2
3
4
5
6
7
8
9
10
// generate an object at a distance further than 'minradius' but no further than 'maxradius'
//  from point X,Y

int distance = rand() % (maxradius - minradius) + minradius;
int angle = rand() % 360;

int dx = (int)( cos(angle * PI / 180) * distance );
int dy = (int)( sin(angle * PI / 180) * distance );

GenerateObject( dx + X, dy + Y );
thanks man
Topic archived. No new replies allowed.