rendered paste body/* * stack.c * * Created on: 30.10.2009 * * aus stack.h: * struct stacks{ * int wert; * struct stacks *next; * }; * typedef struct stacks stack; */#include <stdio.h>#include <stdlib.h>#include "stack.h"stack* newStack() { stack *stackp; stackp = malloc( sizeof(stack) ); stackp->next = NULL; return stackp;}void push(stack *s, int i) { stack *newstack = newStack(); newstack->wert = i; newstack->next = s; s = newstack;}int top(stack *s){ if (isEmpty(s) == 0) { printf("top = %i\n", s->wert); return 0; } else { printf("Fehler: Stack ist leer!\n"); return -1; }}int pop(stack* s){ if (isEmpty(s) == 0) { printf("pop %i\n", s->wert); stack *leer = s; s = s->next; free(leer); return 0; } else { printf("Fehler: Stack ist leer!\n"); return -1; }}int isEmpty(stack* s){ if ((s->next == NULL)) { return 1; } else { return 0; }}void printStack(stack* s){ stack *active = s; while (active != NULL) { printf("%i\n", active->wert); active = active->next; }}