I'm making stack implementation in C using pointers and struct. Push and crateStack functions work well (both of them create new element in memory). Anyway, pop function doesnt work and I dont know why, here is code of that function:
int pop(element **lastStackEl)
{
int poppedValue = *lastStackEl->value;
element *temp = *lastStackEl->prev;
free(*lastStackEl);
*lastStackEl=temp;
return poppedValue;
}
And here is my struct:
typedef struct Element {
int value;
struct Element *prev;
} element;
The compiler's giving error in first and second line of pop function:
error: request for member 'value' in something not a structure or union
int poppedValue = *lastStackEl->value;