C 在结构内部使用时的指针相等
一段时间以来,我一直试图让一个指针与另一个指针相等,但它就是做不到,我也不知道为什么 结构包括:C 在结构内部使用时的指针相等,c,pointers,equals,c89,C,Pointers,Equals,C89,一段时间以来,我一直试图让一个指针与另一个指针相等,但它就是做不到,我也不知道为什么 结构包括: typedef struct{ struct listNode* next; } listNode; typedef struct{ listNode* head; } linkedList; 但是在代码中,当我尝试执行时: 节点->下一步=列表->头部 我收到“来自不兼容指针类型的赋值”错误。 任何帮助都将不胜感激,因为我真的能看到任何错误! 谢谢您在上方的typedef中提
typedef struct{
struct listNode* next;
} listNode;
typedef struct{
listNode* head;
} linkedList;
但是在代码中,当我尝试执行时:
节点->下一步=列表->头部
我收到“来自不兼容指针类型的赋值”错误。
任何帮助都将不胜感激,因为我真的能看到任何错误!
谢谢您在上方的
typedef
中提到了一个struct listNode
,但是没有声明
你需要按正确的顺序做事:
+----At this point, we can refer to "struct listNode"
v
struct listNode {
struct listNode *next; /* We know this self-references, uses the same name. */
};
/* Now establish a shorthand name for the struct ... */
typedef struct listNode listNode;
/* ... which we can use in subsequent declarations like this. */
typedef struct {
listNode *head;
} linkedList;
您在上方的
typedef
中提到了一个struct listNode
,但没有声明
你需要按正确的顺序做事:
+----At this point, we can refer to "struct listNode"
v
struct listNode {
struct listNode *next; /* We know this self-references, uses the same name. */
};
/* Now establish a shorthand name for the struct ... */
typedef struct listNode listNode;
/* ... which we can use in subsequent declarations like this. */
typedef struct {
listNode *head;
} linkedList;