Input:
Input: Default Value
12345678910111213141516171819202122232425
#include <iostream> #include <string> #include <sstream> using namespace std; int main() { int a=17; string input; cout << "enter a (hit enter for default=17): "; getline(cin,input); if (input.length()>0) { stringstream(input)>>a; } cout << "a=" << a << endl; cout << "\nhit enter to quit..."; cin.get(); return 0; }
enter a: 17