-
Help Please!
I was wondering how I can take a string entered in and separate it so I can use individual characters.
Example:
user enter in "3 + 4 + 8 * 9 / 3 + 4"
I want to get all those characters seperately and then be able to apply the order of operations.
I'm not finding much out in any of the books I have.
Any help will be very appreciated.
-
If the user is entering it all as a string, then you will need to tokenise your string. 'strtok' is useful for this. Everybody has a preference but that's an OK place to start.
-
You can calculate arithmetic expressions by converting it from infix to postfix form.
eg. infix : 3+4
postfix : 34 +
The algorithm for this is available in Data structure books,preferably by tremblay and sorenson.