I am trying to write a math engine. The problem I've encountered is that if a user enters say:
add(12345,12345)
then how do I know how many digits to read.
Any solutions?
Printable View
I am trying to write a math engine. The problem I've encountered is that if a user enters say:
add(12345,12345)
then how do I know how many digits to read.
Any solutions?
You read until there are no more digits left to read. isdigit() would be a helpful function in parsing this out.
You could use some fancy sscanf work if they're going to be using a standard format.
<operator><paren><op1><,><op2><paren>
Quzah.
It seems to me that if you are inputting strings you will want to worry about this, but why wouldn't you use floats or ints or something else that isn't a string for your input?
- Edward