C icon indicating copy to clipboard operation
C copied to clipboard

Refactor stack implementation using global top pointer

Open IshuSinghSE opened this issue 4 months ago • 0 comments

This pull request refactors the stack implementation in Program.c from a function-based approach using root pointers to a simpler global-pointer design and introduces a menu-driven interface for user interaction. The changes improve usability and code clarity by consolidating stack operations and providing interactive options.

Refactoring and simplification of stack operations:

  • Replaced the previous function-based stack implementation (using root pointers and helper functions like newNode, isEmpty, and peek) with a global top pointer and direct stack manipulation functions: push, pop, and display.
  • Simplified push and pop functions to operate directly on the global top pointer, removing the need to pass pointers and return values.

User interface improvements:

  • Added a menu-driven loop in main to allow users to interactively push, pop, and display stack elements, with clear prompts and feedback for each operation.
  • Implemented a new display function to show all stack elements, enhancing visibility of stack contents during program execution.

IshuSinghSE avatar Sep 07 '25 14:09 IshuSinghSE