Originally posted by: Odoacer
Stringstream is the proper way. atoi() will work, but is not standard. Your compiler may or may not support it.
I think it's the most comfortable way to convert the chars (and that the way I did it in my HW), but it works just on numbers in the range 0-9.. is there a similiar way for numbers out that range?Subtract decimal 48 or hex 30 from the integer chars to convert to an integer
I tried it & had a problem when I compiled the program: Call to undefined function 'atoi' in function main()Or just use atoi() to convert to integers.
sorry, I didn't understand it..Originally posted by: BingBongWongFooey
Or the "real" c++ way: streams.
int one;
std::stringstream("1") >> one;
That's what I'll do, I think. Thanks!For the operators you will want to use a select case statement most likely since there are only 4 possibilities.
Define directive needs an identifier
It sounds better.Originally posted by: oog
instead of #define, don't you mean #include?
That's an idea, I'll try it!also, the OP also asked about numbers other than 0-9. You can subtract 48 from each character and assemble them into one whole number by multiplying by 10 before adding the next digit
Originally posted by: EagleKeeper
He mispoke.
#include <stdlib.h>