I've been working on a problem, yes for a class, I have to evaluate an expression and do the arithmetic for a string for example "+98-45+34+369+97-198"
where there are no white spaces. I have to parse the string into its components, I know that part. But i'm not sure how exactly to do that. I'm assuming I have to use a for loop to step through the string and locate the "+" or "-" then heres the question do I snip out for example "+98" into string1 and then "-45" to string two and concate them? How do I convert the string to an integer? This has been driving me absolutely insane trying to find out how to do this. I don't really ask for help with stuff usually but this time im completely confused help is appreciated.
You will probably have to do a bit of custom parsing to turn a string into a int, unless there is some other method I do not know of. As for separating the pieces of the string, you can use the find() method to locate the "+" and "-" symbols, then use substr() to get part of the string.