如何修复 "undefined reference to createList"

How to fix "undefined reference to createList"

我正在编写一个程序,用户可以创建单链表并将学生信息输入到列表中,但是我收到一条错误消息 "undefined referance to createList",我该如何解决这个错误?

'''

struct student
{
    int id, age, choice;
    char name[30];
};

struct node
{
    struct student student_data;
    struct node *next;
};

struct node *prependNode(struct node *head);
/*void removeNextNode(struct node *node);*/

struct node *createList(void);

int main(void)
{
    struct node *head = NULL;
    int choice;

    printf("Please select an option: ");
    printf("1. Create\n");
/*      printf("2. Display\n");
    printf("3. Insert\n");
    printf("4. Remove\n");
    printf("5. Search");
    printf("6. Exist");*/
    scanf("%d", &choice);

switch(choice)
{
    case 1:
        head = createList();
        break;
}

return 0;
}

'''

您已经声明了函数 createList 但实际上并未在任何地方定义它。您需要定义函数,或者告诉 compiler/linker file/library 在哪里定义它。

声明:

struct node *createList(void);

定义:

struct node *createList(void)
{
    // implementation here
}