So I implemented a stack, that should turn an infix to postfix but sadly, I can't get it to work for more than 1 digit/character, for example a or 1 works but 12 for example doesn't its treated as 1 2 instead, is there a way I can modify my code to do so?
I thought of a way to ask the user how many variables will he use then let them input the equation in the form of characters so if he wants to have 12 or 123 as a number it'll be stored as character literal 'a' for example and later one when the equation is out I just change it back to infix then calculate the operands using the operators in between them then at the time it'll be that a = 12 or a = 123 so it'll be evaluated that way instead? I hope someone has a better idea
You have a stack of char's that's why you only process a char at a time. You should process a string of characters at a time, rather than just one. For example 100+1 yields three tokens, "100", "+" and "1".