typedef struct node {
int data;
struct node *next;
} Node;
void checkEmpty(Node *list) {
printf(list == NULL ? "true" : "false");
}
The first time, I created the main()
function, made a list
directly in it, and called checkEmpty()
. It printed true
.
int main() {
Node *list;
checkEmpty(list); // it return true
return 0;
}
Then, I created a new function menu()
, created a list
inside it, and called checkEmpty()
. It printed false
.
void menu() {
Node *list;
checkEmpty(list);
}
int main() {
menu(); // it return false
return 0;
}
Why does this happen?