#include using namespace std; int main () { char ch; int num_to_build = 0; cout << "Enter a number " << endl; // eat the blank spaces first cin.get(ch); while (' '== ch) { cin.get(ch); } // we have a non-blank space. // read while we have a digit. while (('0' <= ch) && (ch <= '9') ) { num_to_build = num_to_build * 10 + (ch - '0'); cin.get(ch); } cout << "You entered " << num_to_build << endl; }