Help with random die roller please

So for my college class I am suppose to write a program that will roll a die, get a random result each time and allow the user to change the number of sides on the die.

Everything in my program works when I run it. Except for one thing it isn't random. Every time I roll the die I will get the same result over and over and over until I change the number of sides.

Here is the code if you can help me I would very much appreciate it:

#include <iostream>
#include <ctime>
#include <cstdlib>

using namespace std;

int main(){
srand(time(NULL));
int sides = 6;
int die;
char r;
cout << "You have a 6 sided die. Roll [r], change # sides [c], or quit [q]:\n";
cin >> r;
while(r != 'q'){
{
if (r == 'q') {
cout << "All done!" << endl;
getchar();
}
else if( r == 'c'){
cout << "How many sides?" << endl;
cin >> sides;
}

else if( r == 'r') {
die=(rand()%sides)+1;
cout << "You have rolled a " << die << endl;}

else { cout << "I don't understand...";}
cin >> r;}
}

return 0;
}

Thanks in advance.
Compiled in XCode on Mac. Works fine for me.
What kind of IDE are you using? visual Studio, MonoDevelopment Dev-C++ etc?

also post the source in
source code format
next time.
Instead of srand() try using randomize().
you can still use srand, but you have to use a seed as explained in

http://www.cplusplus.com/reference/clibrary/cstdlib/srand/

for example,
srand ( 1 );
Topic archived. No new replies allowed.