Hi, I am trying to write a program that converts a postfix expression to infix. It works just fine on the first go-around. But when I try to convert another expression, it skips all the user input and terminates. (The sample input I used was simply ab+). Why is this happening? Could anyone give me some advice as to how to fix this?
You probably have something in the input buffer that is being accepted as your new expression.
Try this and see if it helps.
include the <limits> header
#include <limits>
after line 30, add the following so it looks like
1 2 3 4 5 6
cin >> choice; // your original code
// new lines begin
cin.clear(); // reset state of cin
cin.ignore(numeric_limits<streamsize>::max(), '\n'); // discard all input until end of line
// end of new lines
cout << endl << endl; // your original code continues