Consider the following program:
int num;
QTextStream(stdin) >> num;
QTextStream(stdout) << num;
Like this, if I am to incorrectly input a string, or a char, into the variable num
, its value becomes 0 by default.
How can I change the behavior of QTextStream
, so that it stores a different value for incorrect inputs? For example, -1?