bal*_*lky 4 c gcc struct pointers
我在Windows上使用MinGW.我正在构建链表,我对此感到困惑.
#include <stdio.h>
#include <stdlib.h>
typedef struct Data
{
int x;
int y;
struct BlaBla * next; /*compiles with no problem*/
}List;
int main(void)
{
List item;
List * head;
head = NULL;
return 0;
}
Run Code Online (Sandbox Code Playgroud)
我现在结构不能有struct变量(对象,该结构的实例),但可以有该结构类型的指针.不知道指针可以是未显示类型的指针.struct BlaBla * next
;(不是链表,它必须struct Data * next
是一般的说话)
小智 6
是的,您可以,因为编译器在第一次遇到未知类型名称时会假定有一些具有此名称的结构类型定义.然后它将为你声明结构名称,让你用它作为指针,但你不能取消引用它,也不能对它做指针运算(因为它是一个不完整的类型).