链表问题!!!急求

来源:百度知道 编辑:UC知道 时间:2024/06/21 05:08:51
我在编的一道题目:以下函数del完成单向链表中删除值为num的第一个结点
#include<stdio.h>
void main()
struct student
(为什么我调试的时候上面这行说 declaration error??怎么改啊??)
{int info;
struct student *link;
};
struct student *del(struct student *head,int num)
{struct student *p1,*p2;
if(head==NULL)
printf("\nlist null!\n");
else
{p1=head;
while(num!=p1->info&&p1->link!=NULL)
{p2=p1;p1=p1->link;}
if(num==p1->info)
{if(p1==head) head=p1->link;
else p2->link=p1->link;
printf("delete:%d\n",num);
}
else printf("%d not been found\n",num);
}
returen(head);
}

你好,你的结构体struct student要放在main函数的外面定义啊。
而且你的main还是怎么是空的啊?也没有大括号。。

把void main()删除吧!
你现在这是自定义函数
没必要引用主函数