Hey everybody!
My program crashes... and I have no real Idea why.
The basic task here is to implement a program which converts a infix-notation to a postfix-notation. I've done that, it works fine. But on solving the notation, the program somehow crashed.
Two additional notes: We have to use a self-written stack. We can't use the one from the stl. This stack contains strings. The front-function gives the top element, the pop deletes it, the push adds one. Anything else is pretty much stl.
I feel that the program crashes on a conversion.
I'm doing several, all work the same. If anyobody might tell me if this stuff here works, and if not, why not, I'd be glad:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
if (income.front() == "*" )
{
std::stringstream bb(neues.top());
neues.pop();
std::stringstream aa(neues.top());
neues.pop();
float a, b;
bb >> b;
aa >> a;
float c = a*b;
std::string result;
std::ostringstream neuest;
neuest << c;
result = neuest.str();
neues.push(result);
}
Since I did not pop the upper element of the income-list, the element would always stay in the list. The loop, however, still popped the elements from the neues-stack, and boom, an empty stack and a pop-function don't match that well.