c - 错误:第 24 行的 '->' 标记之前应为 ';'、',' 或 ')'
问题描述
/*Add a new node to the top of the list*/
firstlist *insert_top(char entry->name, char entry->address, int entry->phone, firstlist*head)
{
firstlist *new_node;
new_node=(firstlist*)malloc(sizeof(firstlist));
new_node->name=entry->name;
new_node->address=entry->address;
new_node->phone=entry->phone;
new_node->next=head;
head=new_node;
return head;
}
我在第 24 行遇到此错误:错误] 在 '->' 标记之前预期有 ';'、',' 或 ')'
希望大家帮忙。
解决方案
您需要entry->name
从insert_top
函数定义中删除 。
有2种方式可以通过。作为一个结构:
firstlist *insert_top(firstlist *entry, firstlist*head)
那么您可以使用entry
成员,例如entry->name
并稍后调用它:
head=insert_top(entry, head);
另一种选择是使用单独的值:
firstlist *insert_top(char name, char address, int phone, firstlist *head)
那时,您无法使用,entry->name
因为您的函数不知道条目是谁,只需使用name
调用insert_top
此选项与您所做的相同:
head=insert_top(entry->name, entry->address, entry->phone, head);
推荐阅读
- jvm - jvm 是否在依赖第三方 jar 之前加载应用程序类?
- python - 如何通过 BucketType 定义命令错误消息
- swift - 使用 Podfile post_install 钩子添加自定义构建规则
- ssl - 如何获取 SSL 证书以在 Firefox 上使用 Localhost
- python-3.x - 让雷达条形图列跨越条形的整个宽度 - Matplotlib
- python - 无效输入导致 psycopg2.errors.InvalidTextRepresentation
- java - 如何加载以前的数据并使用按钮继续添加其值(数字/整数)?
- python - Spotipy:当我使用 sp.search() 时出现了错误/几位艺术家
- javascript - 未捕获的类型错误:无法读取未定义的属性“toString”--javascript
- python - 将特定单元格定义为 pandas 数据框中的变量