You'll find code a lot easier to debug if you indent it correctly. Master programmers
*always* indent, without fail, because it makes navigating code a lot easier. To investigate your code I started by reformatting it. Make sure you use a programmer-friendly text editor, one that handles indentation correctly and ideally that puts the indentations in for you. If you're using vi, :set ai, and set tabs to something sensible like 4.

You seem to duplicate the top of stack pointer: tctr and s->topelem. It is better not to
do this; you don't need to mess around keeping them in step with each other, and you also don't
risk getting any bugs caused by them accidentally getting out of step. It's fine if you use tctr as temporary storage so that you don't have to keep typing in "s->topelem" all the time, but the code doesn't do that; it relies on these two variables always being equal to each other.

Have another look at the "while ( temp != '(' )" loop. Why does it increment inf every time? What should it do when "temp=s->elem[tctr];" assigns the '(' to temp? Remember the postfix should NOT include any brackets.

Also you might want to look at the number handling logic. 5+(4*3) will currently* result in 543*+, which is fine if you only want to handle single digit numbers, but if you intend to handle numbers over 9 then this looks awfully like five hundred and forty-three.

*i.e. when you've fixed the bugs in the while loop.
shabbir like this