我很困惑!尝试创建动态链接列表并希望通过“malloc”函数分配标题。从我的下面编译代码给出2错误:“节点”的奇怪行为
在主: [错误] node' undeclared (first use in this function) and **In function
newnode ':** [错误]`节点' 未声明(第一在此函数使用)
#include <stdio.h>
#include <stdlib.h>
struct node{
int a,b,c,d;
struct node *next;
};
struct node * newnode(int, int, int, int);
int main(){
struct node *header;
header=(struct node *)malloc(sizeof(node));
int a,b,c,d;
a=11;
b=2;
c=4;
d=5;
header->next=newnode(a,b,c,d);
printf("\n\n");
system("PAUSE");
return 0;
}
struct node * newnode(int aa, int bb, int cc, int dd)
{
struct node *temp;
temp=(struct node*)malloc(sizeof(node));
temp->a =aa;
temp->b =bb;
temp->c =cc;
temp->d =dd;
temp->next=NULL;
return temp;
}
我欣赏任何建议!谢谢!
是BRO!谢谢! –