这是我试图完成的用于构建链接列表的代码片段。由于某种原因,我在尝试编译代码时不断收到错误“错误:预期‘;’、标识符或‘(’在‘结构’之前””。有人可以帮助我吗?
struct node;
struct node* buildList(int x);
void push(struct node** headRef, int data);
int findLen(struct node** headRef);
struct node{
int data;
struct node* next;
}
struct node* buildList(int x){
struct node* head = NULL;
head = malloc(sizeof(struct node));
head->data = x;
head->next = NULL;
return head;
}
最佳答案
尝试在结构声明后添加分号
struct node{
int data;
struct node* next;
};
关于c++ - C 中的链表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28864444/