Here is the main.cpp from my program .Everything works fine when the while loop is not there...i.e..it is done only once..
Code:
#include <iostream>
#include <string>
#include "token.h"
#include "rpn.h"
#include "shunt_y.h"
using namespace std;
int main()
{
deque<token> dt;
char q;
string input;
while(1)
{
cout<<"Enter the expression:\n>";
getline(cin,input);
dt = tokenize(input);
dt = infix_to_rpn(dt);
cout<<rpn_eval(dt)<<endl<<"Quit?\n>";
cin>>q;
if (q == 'y' )break;
else continue;
}
return 0;
}
At runtime....whenever I opt not to quit....the input string automatically assumes a garbage value...not letting me into type into the prompt...
Looks somewhat like the following quote:
Enter the expression:
>log ( 10 ^ 5 ) - sin ( 3.142 / 2 )
4
Quit?
>n
Enter the expression:
>0
Quit?
>n
Enter the expression:
>0
Quit?
>
and so on...