Implementation of dynamic stack in c