Stephen Friederichs ● April 20, 2013 ● ● Coded in April 20, 2013Coded in C

This code snippet implements a basic stack in C. The interesting part is that the implementation uses data hiding to shroud the internal details of the stack. There are two separate stack implementations: a stack growing up and a stack growing down. This is to demonstrate that the specific implementation of an object can't be relied on - only the public API.

This snippet is technically three separate files - a header and two separate implementations. Preprocessor defines can control which implementation is used. This file could be compiled with Cygwin GCC 4.5.3.

Update: Several people correctly pointed out I never checked for NULL pointers in considering the validity of the stack. Good catch. Fixed.