T
Thomas Kreuzer
Hello everyone,
I have a question regarding how to interpret a string.
Basically I want to write a little calculator, I will type something
like "12+69*12-44/2" and then want my program to compute it into the
result
I experimented a bit with strtok and the like, but I think I am not sure
how I should approach this problem. The problem being the priorities of
the operators of course.
Should I split the string? Right now I just put all numbers in a list,
so I would get:
12->69->12->44->2
Now I could make the same for the signs like +->*->-->/ and try to sort
things out and so on, I am really not sure.
Anyone got a hint for me how to do this?
I am thankful for any idea.
Thomas
I have a question regarding how to interpret a string.
Basically I want to write a little calculator, I will type something
like "12+69*12-44/2" and then want my program to compute it into the
result
I experimented a bit with strtok and the like, but I think I am not sure
how I should approach this problem. The problem being the priorities of
the operators of course.
Should I split the string? Right now I just put all numbers in a list,
so I would get:
12->69->12->44->2
Now I could make the same for the signs like +->*->-->/ and try to sort
things out and so on, I am really not sure.
Anyone got a hint for me how to do this?
I am thankful for any idea.
Thomas