Drawing Rectangles using mouse input

I’m currently programming a simple drawing package in C, but I’m having some difficulty at drawing rectangles. Basically, I want the user to first select which point he wants the top left hand corner to be using the mouse, then click where he wants the bottom right hand corner to be, causing the program to draw a rectangle. I’ve heard of rubber bands!, but I’m not sure how it works. If anyone could advise me, or even give me a snippet of code with information on how it works, that would be great. Thanks

If you are using glut, you get the coordinates of the mouse(in pixels) when, in example, a mouse button is clicked.
You can then translate them in to ‘world coordinates’ using gluUnProject.