This is probably not what you want to hear but the easiest way to do this would probably be using lex & yacc. You can define a grammar which tokenises the integers and operators and gives you a tree structure. After that you just iterate through the tree and evaluate the expressions.
I have not done this myself in lex & yacc but I have written the basic grammar in yecc:
Code:
Nonterminals expr statement function params.
Terminals 'integer' 'var' '+' '-' '*' '/' '(' ')' '=' ',' 'and' 'or' '=='.
Rootsymbol statement.
Left 100 '+'.
Left 100 '-'.
Left 100 'or'.
Left 200 '*'.
Left 200 '/'.
Left 200 'and'.
Unary 600 '-'.
Unary 600 '+'.
statement -> statement ',' statement : {sequence, '$1', '$3'}.
statement -> expr : '$1'.
statement -> function : '$1'.
expr -> expr '+' expr : {add, '$1', '$3'}.
expr -> expr '-' expr : {subtract, '$1', '$3'}.
expr -> expr '*' expr : {multiply, '$1', '$3'}.
expr -> expr '/' expr : {divide, '$1', '$3'}.
expr -> expr 'and' expr : {land, '$1', '$3'}.
expr -> expr 'or' expr : {lor, '$1', '$3'}.
expr -> expr '==' expr : {eq, '$1', '$3'}.
expr -> '(' expr ')' : '$2'.
expr -> '-' expr : {negative, '$2'}.
expr -> '+' expr : {positive, '$2'}.
expr -> 'integer' : '$1'.
expr -> 'var' '(' params ')' : {funccall, '$1', '$3'}.
expr -> 'var' '(' ')' : {funccall, '$1', nil}
expr -> 'var' : {funccall, '$1', nil}.
function -> 'var' '(' params ')' '=' expr : {funcdef, '$1', '$3', '$6'}.
function -> 'var' '(' ')' '=' expr : {funcdef, '$1', nil, '$5'}.
params -> 'var' ',' params : {param, '$1', '$3'}.
params -> 'var' : {param, '$1', nil}.
That is a bit more complex and allows you to do assignment. However this is just a starting point and probably more than what you want.
To actually answer the question you asked:
A good idea would probably be to, isntead of making a new postfix string, create a tree which represents the expression and then recurse through the tree to evaluate. In order to evaluate the string you should write a finite state machine. This means instead of looking for an operator such as '-' or '+', and assuming it's a binary operator you figure out what it should be based on the current state and the input token. So for instance to evaluate "-2" you would first probably wan tot break it up into tokens, in this case you have '-' being an operator, then '2' being a number. Then you evaluate this data with a fsm. you have an initial state, you see the '-' operator, and decide wether to reduce or shift, move onto a new state, see the '2' and decide to reduce or shift.
I think that, if anything, I have just made your much more confused about what is going on but perhaps I have given you some good google search terms. If you ask some more questions I'll try to take the time to give you more useful and coherent answers.
Sorry