C 创建块类型结构的单链接列表

C 创建块类型结构的单链接列表,c,linked-list,typedef,C,Linked List,Typedef,我正在尝试创建一个包含这3个typedef struct person、Stats和vehicle的单链表 #include <stdio.h> #include <stdlib.h> #include <string.h> typedef struct{ char name[22]; char city[10]; int yearBorn; } person; typedef struct{ int height[8]; dou

我正在尝试创建一个包含这3个typedef struct person、Stats和vehicle的单链表

#include <stdio.h>
#include <stdlib.h>
#include <string.h>


typedef struct{
  char name[22];
  char city[10];
  int yearBorn;
}  person;


typedef struct{
  int height[8];
  double weight[18];
  }  Stats;

typedef struct{
 char car[16];
 int horsepower[20];
}  vehicle;


typedef struct node {
   person   *p; 
   Stats *stat;
   vehicle *hp;
   struct node *next;
}NODE;

typedef struct {
   NODE *head, *tail;
}SLL;


int main(){
void insert(SLL *list, person p, vehicle hp,  Stats stat){


a = (NODE *)malloc(sizeof(p));
b = (NODE *)malloc(sizeof(hp));
c = (NODE *)malloc(sizeof(stat));

if(list->head == NULL){
 return NULL;
}
list -> head -> next = a;
list -> head -> next-> next  = b;
list -> head -> next-> next -> next = c;
list -> tail = c;


}




return 0;
}
我不断收到a、b和c的错误,说错误:“a”未声明此函数的首次使用。 我只是想知道我是否做得很好,这个错误意味着什么。 我真的很感激任何关于我的代码的见解。多谢各位

问题就在这里

int main(){
    void insert(SLL *list, person p, vehicle hp,  Stats stat){


    a = (NODE *)malloc(sizeof(p));
    b = (NODE *)malloc(sizeof(hp));
    c = (NODE *)malloc(sizeof(stat));

      if(list->head == NULL){
         return NULL;
      }
    list -> head -> next = a;
    list -> head -> next-> next  = b;
    list -> head -> next-> next -> next = c;
    list -> tail = c;
    }

return 0;
}

如何在其他函数中定义函数

您需要在使用变量之前声明它。这里没有声明a、b、c,您直接使用它。我应该声明它是什么?一个未签名的字符?不,你做得不对。如果是,则不会从编译器中获取错误消息。错误消息的意思与它所说的完全相同。代码的问题在于int main后面没有一行正确或有意义的行。在试图重写它之前,您需要花几个小时刷新函数、变量和类型的基本概念。它必须是您在malloc调用之前用于类型转换的类型。所以必须知道使用malloc在堆上创建内存的ie结构是什么类型。还将该函数从main中删除。您是否来自Python背景?在C语言中,在使用变量之前必须声明变量。此外,您不能在函数中定义函数。