Popping element

In C, when you create a pop function for the stack, do I need to rearrange each index, or can I just delete the superscript and everything will shift to 1 place on it?

+3
source share
1 answer

When implementing the stack, you should click and place it at the end of the array, not at the beginning. Thus, nothing should move. In fact, if your elements do not need to be cleared (without pointers, etc.), then the pop file is as simple as decreasing the top stack variable.

+5
source

Source: https://habr.com/ru/post/1747729/


All Articles