Thoughts:
- In
push()
, you test for equality instead of performing assignment. temp
is of type int. It should be a float.empty()
takes no arguments, and you pass it one.- The last
printf("%f", top())
will invoke undefined behavior, because you will printsta.data[-1]
. - You don't really need the while loop and the for loop around the
pop()
printing. You should be able to just do the while loop. - To make your output more readable, you should probably print
'\n'
characters after each float, which will make each float be seen on their own line.
Once these errors are fixed, the code appears to work correctly: