Parsing Input from Stack

Reply

Join Date: Oct 2006
Posts: 17
Reputation: blazted is an unknown quantity at this point 
Solved Threads: 0
blazted blazted is offline Offline
Newbie Poster

Parsing Input from Stack

 
0
  #1
May 25th, 2007
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
Reply With Quote Quick reply to this message  
Join Date: Jul 2005
Posts: 1,894
Reputation: Lerner is a name known to all Lerner is a name known to all Lerner is a name known to all Lerner is a name known to all Lerner is a name known to all Lerner is a name known to all 
Solved Threads: 300
Lerner Lerner is offline Offline
Posting Virtuoso

Re: Parsing Input from Stack

 
0
  #2
May 25th, 2007
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.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:




Views: 1193 | Replies: 1
Thread Tools Search this Thread



Tag cloud for C++
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2010 DaniWeb® LLC