943,928 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Unsolved
  • Views: 1316
  • C++ RSS
May 25th, 2007
0

Parsing Input from Stack

Expand Post »
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
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
blazted is offline Offline
17 posts
since Oct 2006
May 25th, 2007
0

Re: Parsing Input from Stack

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.
Reputation Points: 718
Solved Threads: 373
Nearly a Posting Maven
Lerner is offline Offline
2,253 posts
since Jul 2005

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: handheld telnet emulation
Next Thread in C++ Forum Timeline: Why does this work?





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC