Try to exit program

I would like to exit program with characters too instead of numbers other than '1', How?

int choice;
cin>>choice;
if(choice==1)
{
cout<<"number is one"<<endl;
}
else
{
exit(0)
}
Last edited on
Make choice a char.

1
2
3
4
5
6
7
8
9
10
char choice;
 cin>>choice;
 if(choice=='1')
 {
 cout<<"number is one"<<endl;
 }
 else
 {
 exit(0)
 }
Topic archived. No new replies allowed.