/* Jason Boxall 1/16/96 CSC 131 Lab #8 */
/* this program uses a 2D array and implements it as a stack */
#include
int push(char *[],int);
int pop(int);
void display(char *[],int);
void main()
{
char *names[3]={"Ed Brown\0","Ann Smith\0","Sue Jones\0"};
int count=3;
puts("The original stack is as follows:");
display(names,count);
puts("After popping the top name, the stack is as follows:");
display(names,pop(count));
push(names,count);
puts("After pushing on a name, the stack is as follows:");
display(names,count);
}
int pop(int count)
{
return --count;
}
void display(char *n[3],int count)
{
int i;
for(i=(count-1);i>=0;--i)
printf("%s\n",*(n+i));
puts("");
}
int push(char *n[3],int count)
{
puts("Enter a name:");
gets(*(n+(count-1)));
puts("");
return count++;
}