-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstack_test.c
More file actions
32 lines (29 loc) · 798 Bytes
/
stack_test.c
File metadata and controls
32 lines (29 loc) · 798 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#include "stack.h"
struct data{
int *x;
int y;
};
void wrapper(stack * st, struct data * result){
popStack(st, result);
}
//Routine to test & debug the Stack datastructure.
//INSIGHT: literally declared strings and char pointers have different sizes, be careful of this
int main(int argc, char **argv){
struct data *test = (struct data *) malloc(sizeof(struct data));
test->x=NULL;
test->y=5;
stack dataStack; //create stack
newStack(&dataStack, sizeof(struct data)); //initialize stack
pushStack(&dataStack, test);
struct data* res = (struct data *) malloc(sizeof(struct data));
wrapper(&dataStack, res);
/**struct data* foo;
foo = &res;
struct data* bar;
bar = foo;
foo = NULL;*/
printf("%i\n", res->y);
destroyStack(&dataStack); //destroy stack
free(test);
free(res);
}