/* program to allow experimentation of several stack implementations */

#include <stdio.h>
#include <string.h>
#include <stdlib.h>

/* include successive stack implementations with the following line */
#include "stack.h"

int
main (void)
{
  /* set up stack variable */
  struct string_stack * p_stack = initialize ();

  if (p_stack == NULL)
    return EXIT_FAILURE;
  
  printf ("program to follow status of string variables during processing\n");
  printf ("progress commentary      a     b     c     d     e     f     g     h\n");

  char a[6] = "apple";
  char b[6] = "beans";
  char c[6] = "corn";
  printf ("initialize a, b, c  ");
  printf (" %5s %5s %5s\n", a, b, c); 

  /* push a, b, c on stack */
  push (p_stack, a);
  push (p_stack, b);
  push (p_stack, c);

  /* pop stack 3 times */
  char * d = pop (p_stack);
  char * e = pop (p_stack);
  char * f = pop (p_stack);
  
  printf ("pop to get d, e, f  ");
  printf (" %5s %5s %5s %5s %5s %5s\n", a, b, c, d, e, f); 

  /* change a, e */
  strcpy (a, "fruit");
  strcpy (e, "peas");
  printf ("change a, e         ");
  printf (" %5s %5s %5s %5s %5s %5s\n", a, b, c, d, e, f);

  /* create new strings g, h and push on stack */ 
  char g[6] = "Beet";
  char h[6] = "Olive";
  push (p_stack, g);
  push (p_stack, h);

  printf ("push new g, h       ");
  printf (" %5s %5s %5s %5s %5s %5s %5s %5s\n", a, b, c, d, e, f, g, h);

  /* change g */
  strcpy (g, "Dill");
  printf ("change g            ");
  printf (" %5s %5s %5s %5s %5s %5s %5s %5s\n", a, b, c, d, e, f, g, h);

  free(p_stack);
  return EXIT_SUCCESS;
}
