So I want to get a postfix expression, in just a single line, and store every single character in that expression to a character array. For example, I want to enter this expression:
BTW, I am only using single-digit integers. So, I don't need a string array.
Problem is, when I finish the expression and press ENTER, I get no results. Plus, the program doesn't end properly so I have to press CTRL + C. I tried two schemes but none worked.
Here are the code snippets of the schemes I tried to use for the input:
1 2 3 4 5 6 7
|
int i = 0;
cout << "Enter the expression: ";
while ( token[ i - 1 ] != '\n' ) {
cin >> token[ i ];
i++;
}
|
1 2 3 4 5 6 7
|
int i = 0;
while ( i < 30 ) {
cin >> token[ i ];
if ( token[ i ] == '\n' )
break;
i++;
}
|
Any suggestions, please, on how to solve this?? Thanks a lot :)