so , i have a doubt . when we use in structures in c we declare a pointer of that structure by using typecasting. for example if struct node is the structure then we declare pointer by
head* = (struct node*)malloc(sizeof(struct node));
why cant we just directly use struct node head* ; that is my question
You can.
Then head will point to NULL
Try this
#include<stdio.h>
#include<assert.h>
struct a{
int x;
};
int main(){
struct a* head;
asssert( head == NULL);
return 0;
}
1 Like