dividing string into pieces

hi there,

i made a calculator that you have to give terms and operators one by one but now i want to improve it. the user now should be able to type something like 5*78+325/sin(3*pi)-1 and the program should be able to calculate it. but i don't know how to use the signs '*','+','-' and '/' as delimiters and turn the input string into a string array. i mean the string "5*78+325/sin(3*pi)-1" will become a string array like "5,*,78,+,325,/,sin(3*pi),-,1,"

any suggestions?
Last edited on
read the line into a std::string and use find?:

although a bit simplistic for you what you want to do.
Last edited on
strtok() should be a good place to start http://www.cplusplus.com/reference/cstring/strtok/

although i think you will find this getting complicated quickly so i would suggest that you drop the idea of functions until later, and add a single feature at a time, like named constants "pi" and subexpressions in parenthesis etc.

Topic archived. No new replies allowed.