#include<stdio.h>
typedef struct student{
int id;
int mark;
}stud;
typedef struct stud *s1;
void main(){
s1 = NULL;
printf("hi");
}
Please help me how to initialize struct pointer to NULL. i get the following error during compilation.
graph.c: In function ‘main’:
graph.c:11:04: error: expected identifier or ‘(’ before ‘=’ token
You meant to define the variable
s1asLive demo: http://ideone.com/9ThCDi
The reason you got the error you did is that you were declaring
s1to be a type for “pointer to struct stud”. This is wrong for two reasons:s1to be a type; you wanted it to be an object.struct student. But you defined an actual type calledstud.