c - 如何修复“对 createList 的未定义引用”
问题描述
我正在编写一个程序,用户可以创建单链表并将学生信息输入到列表中,但是我收到一条错误消息,提示“未定义对 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
,但并未在任何地方实际定义它。您需要定义函数,或者告诉编译器/链接器定义它的文件/库在哪里。
宣言:
struct node *createList(void);
定义:
struct node *createList(void)
{
// implementation here
}
推荐阅读
- maven-3 - Maven(pom.xml) 在部署/安装阶段不运行插件
- angularjs - 不能在指令模板中使用 ng-repeat
- node.js - 如何使用 sequelize 更改日期时间存储在 postgresql 中的格式?
- c - 创建 C“模板”函数
- javascript - Laravel @include 不会接受来自 JS innerHTML 的变量
- spring-boot - 在 Liquibase 上 Spring boot Support Fast 是否失败
- swift - 将 UIImage 导出为 Messages 应用的贴纸
- python - python中的递归,不覆盖更改的变量
- jenkins - 在 Openshift 中为 Jenkins 实例配置不同的构建工具
- python - FileNotFoundError: [Errno 2] 文件 stock_dfs/BRK.B.csv 不存在:如果文件不存在如何调整代码: