- Joined
- Jul 16, 2012
- Messages
- 679
Hello Hivers
I have a problem...
Look this....
So...
I want to get the 1, 2, 3
If the cin get letters or symbols
must be show Invalid but does not work
I have a problem...
Look this....
JASS:
#include<conio.h>
#include<iostream.h>
main()
{
cout<<"Enter your number: "; /* Only 1, 2, 3 */
cin>>o;
int counter = 1, o;
if( o == 0){
counter = 0;
}else if( o == 1){
q1++;
t = t + c1;
}else if( o == 2){
q2++;
t = t + c2;
}else if( o == 3){
q3++;
t = t + c3;
}else if( o != 1 && o != 2 && o != 3){
cout<<"Invalid: "<<o;
}else
cout<<"Invalid: "<<o; /*Non-numbers */
getch();
return 0;
}
So...
I want to get the 1, 2, 3
If the cin get letters or symbols
must be show Invalid but does not work