我很困惑!尝试创建动态链表并希望通过“malloc”函数分配标题。从我下面的代码编译器给出2个错误:
in main: [Error] node' undeclared (first use in this function) and
**In function
newnode':** [Error] `node' undeclared (第一次在这个函数中使用)
#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;
}
我很感激任何建议!谢谢你!