I have trying to parse string data in a stack into a arithmetic equivalent. I implemented a stack and used strtok to parse it into tokens and placed them into my stack. Now I am trying to pull them off the stack and do the expression that is carrying them. But I am lost on how to do this. On my Stack I will have ( 2 + 2) + 3 and I can pop them off at a time to get to keep the correct order but I have no idea how to make them into an equation from the stack. Can any body point me to a way to do this? I am not looking for code but some type of explanation on how to create this. I can pull them off the stack and know how to convert the doubles into doubles but how can i assign this into a string for the program to do the math?

Thanks

Declare a char variable to hold the math operator you want to use, then pass the operator to a switch statement where each case of the switch statement implements the desired math procedure desired based on the char passed.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.