I'm trying to create my stack, using my linked listed functions that I already created. I have the following:
listNode *createList()
{
listNode *anyNode;
anyNode = malloc(sizeof(listNode));
anyNode->next = NULL;
return anyNode;
}
stack *createStack()
{
stack *temp;
stack.list = createList();
return temp;
}
and in my main I call it using:
int main(void)
{
stack *theStack;
theStack = createStack();
return(0);
}
I defined my stack as:
typedef struct stack {
listNode *list;
}stack;
I get a compiler error: expected identifier or '(' at my stack.list = createList() call in my createStack function. I'm not sure why.
My main works if I change
stack *theStack
into
listNode *list
then just call it as: list = createList();
return(0)looks as ifreturnwas a function, it's not.