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) ); return stackp;}void push(stack *s, int i) { stack *newstack; newstack = newStack(); newstack->wert = i; newstack->next = s; s = newstack;}int top(stack *s){ if (isEmpty(s) == 0) { return (s->wert); } else { printf("Fehler: Stack ist leer!\n"); return -1; }}int pop(stack* s){ if (isEmpty(s) == 0) { int temp = s->wert; stack *leer = s; s = s->next; free(leer); return temp; } else { printf("Fehler: Stack ist leer!\n"); return -1; }}int isEmpty(stack* s){ if ((s == NULL)) { return 1; } else { return 0; }}void printStack(stack* s){ stack *active = s; while (active != NULL) { printf("%i\n", active->wert); active = active->next; }}