* 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 [][15],int);
int pop(int);
void display(char [][15],int);
void main()
{
char names[][15]={"Ed Brown","Ann Smith","Sue Jones"};
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[][15],int count)
{
int i;
for(i=(count-1);i>=0;--i)
printf("%s\n",(n+i));
puts("");
}
int push(char n[][15],int count)
{
puts("Enter a name:");
gets(n[count-1]);
puts("");
return count++;
}