Let's say I have a string with 1+5*9+4 etc.. whatever it may be. How do I use C++ do calculate this? I know recursive functions work here, but how? I figured I could loop ..searching for the * first ( higher precedence ) and then the +. No idea. Would not be a recursive function, would it? What does this function look like for this example?
XodoX
0
Junior Poster in Training
Recommended Answers
Jump to PostYou could do as SnowFall if and only if you are allowed to use other libraries to build the function. Otherwise, you better build your own parser first. Also, does the incoming string could contain parenthesis as well? Watch out for that as well...
All 3 Replies
rubberman
1,355
Nearly a Posting Virtuoso
Featured Poster
SnowFall
0
Newbie Poster
Taywin
312
Posting Virtuoso
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.