I have a string which may contain either single integers between 0-9
or mathematical operators (+, -, *, /)
.
Basically, I need to read in all characters / numbers. I am checking if the character is either +,-,* or /. If not, then I know it is either a number or an invalid character. I am using atoi to convert it to an integer. atoi will return 0 in both cases: if the integer is a 0 OR if it was an invalid character.
How else can I make this distinction?
Check each character with standard isdigit() function before using atoi