Hello,

I want my program to repeat it self if the user entered a specific number and to terminate if he entered any other number or charcter

the repeating part worked put the terminating part did not . it kept on doing an infinate loop

how can I fix it ? what would the condition be like?

(I used a do while loop)

const int REPEAT_CODE = 666;
int userInput = 666; //could be any value for now

do{
runGame();
getInput();
}while(REPEAT_CODE == userInput);

well I did it like this

do {

cout<<"If you want to continue press 1 .. otherwise press any key to exit"<<endl;
cin>>key;
} while(key==1)

it works if the user entered 1
but it gives an infinate loop if the user entered anything else
how do I make it stop and exit if the user entered anything other than 1 ?

There must be something else thats wrong with your code then. Want to post it?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.