I've just noticed that you have another problem with your code:
Code:
$ make foo
cc -Wall -Wextra -ggdb3 foo.c -o foo
foo.c: In function ‘pushStack’:
foo.c:28:6: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
foo.c:30:17: warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘int *’ [-Wformat]
foo.c: In function ‘print’:
foo.c:44:18: warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘void *’ [-Wformat]
foo.c: In function ‘main’:
foo.c:69:5: warning: passing argument 2 of ‘pushStack’ makes pointer from integer without a cast [enabled by default]
foo.c:25:6: note: expected ‘void *’ but argument is of type ‘int’
foo.c:70:5: warning: passing argument 2 of ‘pushStack’ makes pointer from integer without a cast [enabled by default]
foo.c:25:6: note: expected ‘void *’ but argument is of type ‘int’
foo.c:72:5: warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘int *’ [-Wformat]
Code:
pushStack(stack, 10);
pushStack(stack, 20);
These two lines push memory addresses (0xa and 0x14) on the stack because the second parameter of pushStack() is a pointer to void.
Bye, Andreas