Pointers 将typedef结构指针初始化为NULL

Pointers 将typedef结构指针初始化为NULL,pointers,struct,initialization,typedef,Pointers,Struct,Initialization,Typedef,您打算将变量s1定义为 graph.c: In function ‘main’: graph.c:11:04: error: expected identifier or ‘(’ before ‘=’ token 现场演示: 出现错误的原因是您将s1声明为“指向结构stud的指针”的类型。这是错误的,原因有二: 你不希望s1成为一种类型;你想让它成为一个物体 您的结构是struct student。但是您定义了一个名为stud的实际类型 使用struct student*s1 而不是 类型

您打算将变量
s1
定义为

graph.c: In function ‘main’:  
graph.c:11:04: error: expected identifier or ‘(’ before ‘=’ token
现场演示:

出现错误的原因是您将
s1
声明为“指向结构stud的指针”的类型。这是错误的,原因有二:

  • 你不希望
    s1
    成为一种类型;你想让它成为一个物体
  • 您的结构是
    struct student
    。但是您定义了一个名为
    stud
    的实际类型

  • 使用struct student*s1

    而不是

    类型定义结构螺柱*s1

    据我所知,只有在定义自定义数据类型时才使用typedef

    graph.c: In function ‘main’:  
    graph.c:11:04: error: expected identifier or ‘(’ before ‘=’ token
    
    stud *s1;