A
aurgathor
I have a code that reads in 2 shorts, and checks if they are
in a given range. I'd like to modify it to use a predefined
default value if nothing, but as newline is entered. What
would be the best way to do that?
TIA
current code:
do {
cout << " Rows [" << MIN_ROWS << ".." << MAX_ROWS << "](" << DEF_ROWS <<
"): ";
cin >> rows;
cout << "Colums [" << MIN_COLS << ".." << MAX_COLS << "](" << DEF_COLS
<< "): ";
cin >> cols;
\n";
cout << "Please re-enter, or ^C to abort: \n\n";
}
} while ((rows < MIN_ROWS) || (rows > MAX_ROWS) || (cols < MIN_COLS) ||
(cols > MAX_COLS));
in a given range. I'd like to modify it to use a predefined
default value if nothing, but as newline is entered. What
would be the best way to do that?
TIA
current code:
do {
cout << " Rows [" << MIN_ROWS << ".." << MAX_ROWS << "](" << DEF_ROWS <<
"): ";
cin >> rows;
cout << "Colums [" << MIN_COLS << ".." << MAX_COLS << "](" << DEF_COLS
<< "): ";
cin >> cols;
cout << "Values for rows and colums must be in the indicated rangeif ((rows said:MAX_COLS)) {
\n";
cout << "Please re-enter, or ^C to abort: \n\n";
}
} while ((rows < MIN_ROWS) || (rows > MAX_ROWS) || (cols < MIN_COLS) ||
(cols > MAX_COLS));