can u please correct this code i made?
its supposed to push,pop,makeempty,empty and print, depending on the choice of the user.. u'll get the idea.. here's the code..
can u please revise it and highlight what you've changed..
i would really appreciate this.. thanks in advance..
Quite a few issues here:
1) Please enclose your code in block so that it's readable
2) you call getch() right after return 0. getch() will NEVER get called
3) When you start i assume your stack is empty, now when your stack is empty i believe you want top = -1, but this is not what will happen as top has not been explicitly defined to be -1 at the beginning. Technically speaking the value of top is undefined but typically it'll be 0 not -1.
4) Really minor but your code seem to be C-sytle not C++-style (Based on your function calls etc). I don't really care but if it's meant to be C++ code i've found that some ppl mind if you use alot of C functions
5) Even smaller and is just a manner of opinion, but should Print really pop from the stack?