Question: Using C, make a stack [ push() and pop()] of ints. At first, the stack should be able to hold 5 items. If you try
![Using C, make a stack [ push() and pop()] of ints.](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2024/09/66f3176f8f4b9_27966f3176f2e157.jpg)
Using C, make a stack [ push() and pop()] of ints. At first, the stack should be able to hold 5 items. If you try to push() onto a full stack, you should allocate a new block of memory for the stack then move over the items from the old stack, reassign the pointers, and then deallocate the old stack. You should try doubling the stack when you reach the limit. Don't allocate unnecessary amounts of memory, so if you had allocated 10 spaces and you only used 2, you should reallocate the stack size to 5. When reallocating, keep track by printing 'increasing/decreasing size from a to b
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
