All pastes #955413 Raw Edit

stack

public c v1 · immutable
#955413 ·published 2008-03-24 16:34 UTC
rendered paste body
#include <stdio.h>#include <stdlib.h>#define STACKSIZE 20typedef char info_t;typedef struct s{info_t S[STACKSIZE];int top;} stack;void init(stack *m){m->top = -1;}void stackOverflow(){	fprintf(stderr, "ERROR: StackOverFlow\n");	exit(-1);}void stackUnderflow(){	fprintf(stderr, "ERROR: StackUnderFlow\n");	exit(-1);}void push(stack *m, info_t x){if(m->top >= STACKSIZE)	stackOverflow();	m->S[++(m->top)]=x;}info_t pull(stack *m){if(m->top < 0)	stackUnderflow();		return(m->S[(m->top)--]);}info_t Peek(stack *m){if(m->top < 0)	stackOverflow();	return(m->S[(m->top)]); }int isEmpty(stack *m){	return((m->top) < 0);}int main(){return 0;}