struct node {
int data;
struct node *next;
};
int main() {
struct node *head = malloc(sizeof(struct node));
struct node *current = head;
...
};
Though this piece of code can run without any warning or error, Valgrind will give some messages saying Conditional jump or move depends on uninitialised value(s)
, Uninitialised value was created by a heap allocation
I can't figure out what's going wrong. We defined a node
struct outside the main
function. So I think we can use sizeof(struct node)
, isn't it?