gpt4 book ai didi

c - 如何从结构中返回头部

转载 作者:行者123 更新时间:2023-11-30 18:51:04 24 4
gpt4 key购买 nike

我尝试返回头部的代码:

node insert(node *head, int num){
node *newnode;
newnode=getnode();
newnode->data=num;
nednode->next=NULL;

if(head==NULL){
head=newnode;
newnode->next = NULL;
}
head->next=newnode;
return head;
}

编译后,我收到此错误:

"error: expected declaration specifiers or '...' before '*' token"

提前致谢

最佳答案

您的函数原型(prototype)似乎不完整:

node insert(*head,num)

应该是:

node insert(node *head, int num)

关于c - 如何从结构中返回头部,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38343336/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com