char Action, else if question...

closed account (LAfSLyTq)
How do i make it to where if i dont enter a valid command, my program does nothing?
emample...

1
2
3
4
5
6
7
8
9
10
	cin>>Action;
	if(Action=='1')
	{
		cout<<"Confirmed"<<endl;
	}
	if(Action=='2')
	{
		cout<<"Denied"<<endl;
	}
\\Code for doing nothing here.
Last edited on
code tags dude!!!

1
2
3
4
5
if(credential_variable == true){
   //do stuff
} else {
   //send you don't have permission etc.
}
closed account (LAfSLyTq)
yes but how do i make it to where it doesnt continue the code until you enter a valid command?
closed account (LAfSLyTq)
Bump.
@Invader2010
1
2
3
4
5
6
7
char Action = ' ';
do
{
cout << "What action ? (1 or 2)" << endl;
cin >> Action;
} while (Action < '1' || Action > '2');
// Now do whatever Action 1 or Action 2, is supposed to do. 


Hope this helps
Topic archived. No new replies allowed.