I have made a program to make a rectangle in a text matrix. It begins asking for width and height. The variable must be greater than 2 and a whole number. The only problem is if a user enters a character instead of a number, or a decimal instead of an integer 'm stuck in an infinite loop. How do you determine whether the input is a string, a double type or integer?
do{
cout << "\n\tEnter the width: ";
cin >> w1;
w2 = w1;
w2 = w1;
wf = w1;
inside = w1;
inside_c = w1;
inside-=2;
inside_c = inside;
cout << "\n\tEnter the height: ";
cin >> h;
hf = h;
h-=2;
cout << "\n" << endl;
if(w1<1 || h<1){
w1 = 0;
w2, wf, inside = w1;
h = 0;
hf = h;
cout << "Please enter a number greater than 2. \n" << endl;
error26 = true;}
else{
error26 = false;}
}while(error26 == true);