I don't understand, why cin >> W; in step 3 is omitted, if i input not a number (i.e. 's').
#include <cstdlib>
#include <iostream>
using namespace std;
int main(int argc, char *argv[])
{
short W = -1;
cout << "step 1) W = " << W << endl;
cout << "give a number: ";
cin >> W;
if ( cin.fail() )
{
cout << "ERROR, bad number" << endl;
W = -1;
cout << endl << "step 2) W == " << W << endl;
cin.clear();
}
cout << endl << "step 3) W == " << W << endl;
cout << "give a number: ";
cin >> W;
cout << endl << "step 4) W == " << W << endl;
system("PAUSE");
return EXIT_SUCCESS;
}