I am getting a segmentation fault error in this code taking an infix expression to a postfix expression, I have a lot of debugging code in and I'll leave it in so you can see how far it gets as well. I can't figure out why It is doing this, I have to use my own string library for this which I will include so you can see what stack is using for the strings. This is a lot I am asking to be looked over, but if anyone has the time please assist me! :)
I apologize for string being so sloppy.
This is a link to my string class, it is too long to post in here -
while(tokens[i]!= ";"){ //Are you guaranteed that tokens contains a ";"? If not then you will be trying to read
//uninitialized data. A fix might be: while(i < tokens.size() && tokens[i]!= ";")?
if(tokens[i] != "("){
if(tokens[i] == ")"){
rhs = s.pop();
op = s.pop();
lhs = s.pop();
s.push(lhs + rhs + op);
}
else
s.push(tokens[i]);
}
++i;
}
Do you not have any idea where the error is? Try using breakpoints to narrow it down. And look at the local variables of your code to see if you have a bad pointer somewhere during suspicious functions.