Category : Files from Magazines
Archive   : CUJ9202.ZIP
Filename : 1002022A

 
Output of file : 1002022A contained in archive : CUJ9202.ZIP



#include

#define STACK_TOP 50

static int stack[STACK_TOP];
static size_t stack_ptr = 0;

void push(int value)
{
if (stack_ptr < STACK_TOP)
stack[stack_ptr++] = value;
else
fprintf(stderr, "Stack full: discarding %d\n", value);
}

int pop(void)
{
if (stack_ptr > 0)
return stack[--stack_ptr];
else {
fprintf(stderr, "Stack empty\n");
return 0;
}
}