malloc returns a void pointer. You need to typecast it.

newPtr =(StackNode *) malloc(sizeof
(StackNode));

i think this should work.