APL/APL1.2/TP10/chainee_tables.c

37 lines
623 B
C
Raw Normal View History

2022-01-18 12:52:55 +01:00
#include <stdio.h>
#include <stdlib.h>
typedef char* pile;
void push(pile* p, char c) {
p = (pile*)realloc(p, sizeof(*p) + sizeof(char));
(*p)[(sizeof(*p)/sizeof(char))-1] = c;
}
char pop(pile* p) {
char c = (*p)[(sizeof(*p)/sizeof(char))-1];
p = realloc(p, sizeof(*p) - sizeof(char));
return c;
}
int empty(pile p) {
return p[0] == 0;
}
char top(pile p) {
return p[(sizeof(p)/sizeof(char))-1];
}
void clear(pile* p) {
p = realloc(p, sizeof(char));
(*p)[0] = 0;
}
pile create() {
pile p = (pile)calloc(1, sizeof(char));
return p;
}
pile destroy(pile* p) {
free(p);
}