The ||
operator needs to operate on boolean expressions, which characters are not. You'd need to expand it out to while (inputChar != '1' && inputChar != '2' && ...
.
Alternatively, you could exploit the fact that the character codes of digits are sequential. In other words, you could do while (inputChar < '0' || inputChar > '9')
.
Also, in your CalculateResult
function, you need to change those =
to ==
- otherwise, you overwrite the Operator
variable, rather than comparing to it.