so there is something wrong with the compatibility of my expression variable with everything im trying to use it for. Do I need to create an alias for it to use it the way im am attempting to use it? or reference it as something else?
the build messages are saying "error: no match for operator!= in 'expression.std::vector<_TP, _Alloc>...ect
I am making a program to convert a give integer expression that is in regular notation and converting it to post fix
how would I go about formatting the isdigit and isalpha line to make it a string instead?
isdigit is a function that tests a single character to see if it is a digit. Similarly, the isalpha tests a single character to see if it is an alphabetic character.
So there is no way to "format" these functions to do something they are not written to do. You have to write your own routine to test if an entire string is whatever you feel it should be.
that sounds reasonable. But generally how do I go about formatting my expression[n] variable to be recognized as a string? Like when it is not empty
You have a vector of string. The name of the vector is expression. Each element in that vector is an entire string. So expression[0] is a string, expression[1] is a string, expression[2] is a string.
Well, given a string how do you access a character? You use operator [] on that string. I believe you erroneously used operator [] to access each string in the vector. You need to go one more level to access the actual characters of the string:
Code:
(expression[0]) [0] --> the first character in string 0
(expression[0]) [1] --> the second character in string 0
(expression[1]) [0] --> the first character in string 1
(expression[1]) [1] --> the second character in string 1
etc...
You can remove the parentheses -- I added them so that you can understand what is being done to access each character.
I didnt get any compile errors but Im not sure how to test it without putting it into a tree expression tree yet. Did I implement it the way you meant?
okay here is the real code actually, and i did try and test if the conversion to RPN would print out okay. but for example one of the inputs is "31+25*2"; and all that my code could spit out is "31"
Bookmarks