Relative Content

Tag Archive for c++algorithmdata-structures

Calculating Postfix in c

I have been asked to calculate a postfix expression , which means that for every consequtive 2 numbers there is an arithmetical operation in between , for example fot the given string “123*+” the result will be 7 –> 1+(2*3)
I tried to write the code in C but for some reason i get that the result is 0
can someone tell me why? or if my direction is wrong?
And how can i return to the user that there was an error with the given string such as uknown char or empty string if the function needs to return an int. I can’t return NULL right.?
thank you