0
votes
typedef struct list
{
char* element;
struct list* next;
}listNode;
listNode* stack[100];
int indexStack = 0;
int iteratie = 0;
void push(listNode* node)
{
stack[indexStack++] = node;
}
listNode *pop()
{
if (0 < indexStack) {
 indexStack--;
 listNode* node = stack[indexStack];
 stack[indexStack] = NULL;
 return node;
                    }
 else
 return stack[indexStack];
}
 void undoOperation(listNode** listStart)
 {
 *listStart = pop();
 }

I want to create a stack of lists and my code only saves the first letter (string) of the lists (it stores the first list i guess), do you have any idea of what is wrong?

Please provide a minimal reproducible example which demonstrates your observations. Make sure to feed data which triggers your observation.Yunnosch