home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The C Users' Group Library 1994 August
/
wc-cdrom-cusersgrouplibrary-1994-08.iso
/
listings
/
v_10_02
/
1002022a
< prev
next >
Wrap
Text File
|
1991-12-04
|
405b
|
28 lines
#include <stdio.h>
#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;
}
}