提问人:Foreastbtch 提问时间:5/8/2022 最后编辑:Foreastbtch 更新时间:5/8/2022 访问量:360
在 C 语言中定义结构时的语法错误标识符
Syntax error identifier when defining a struct in C
问:
我已经在 C 文件中定义了这些结构,但我不知道为什么会出现此编译错误。
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<malloc.h>
#include<string.h>
//using namespace std;
typedef struct Gradina{
char* denumire;
int nrFlori;
float* preturi;
}Gradina;
typedef struct Nod {
Gradina* info;
Nod* next, * prev; //the first syntax error points here
}Nod; //the second error points here
答:
2赞
pmg
5/8/2022
#1
typedef struct Nod { Garden* info; Nod* next, * prev; }Nod;
该类型在最终之前不存在,尤其是在上面的第 3 行。你需要Nod
;
struct Nod* next, * prev;
其中,即使尚未定义,也可以使用指向它的指针。struct Nod
评论
0赞
Foreastbtch
5/8/2022
这在重建后起作用了,谢谢!
评论
Output
Nod
struct Nod
Nod