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:
Enter the expression:
>log ( 10 ^ 5 ) - sin ( 3.142 / 2 )
4
Quit?
>n
Enter the expression:
>0
Quit?
>n
Enter the expression:
>0
Quit?
>
The elsecontinue part doesn't really do anything, it would continue without you telling it to. Have you tried putting cin.ignore(numeric_limits<streamsize>::max,'\n'); after cin>>q;?
This is because you only read a character, but the user actually inputs at least two of them ('y' and either '\n' or '\n' '\r' for example). The user could also write "yes" there. In any case, you have characters remaining in the stream that you will read with the next getline instead of what you actually wanted. And then you cin another character and the same thing happens again.
Yes, because you probably only have a single character after 'y'. Don't rely on that (as I said, you could accidently type "yes" or"yy" or something like that), include limits and do it as I said.
But even when I include limits ...the code isn't compiling. Could there be slight differences in how it is used across platforms?
I am using Ubuntu 10.10 and the gcc compilers ..