C语言 请看下面程序,end 错在哪里?

来源:百度知道 编辑:UC知道 时间:2024/07/02 20:29:39
这个函数中的 end 在编译时出现两个错 :undefine symbol 'end' /lable 'end' 程序和书上是一样的。

struct student *del(struct student *head,long num)
{
struct student *p1,*p2;
if(head==NULL){printf("\nlist NULL!"); goto end;}
p1=head;
while(num!=p1->num&&p1->next!=NULL)
{
p2=p1;
p1=p1->next;
}
if(num==p1->num)
{
if(p1==head)head=p1->next;
else p2->next=p1->next;
printf("delete:%ld\n",num);
n=n-1;
}
else printf("%ld not been found! \n",num);
end;
return(head);
}

你的end 是什么意思,哪里来的end,
不要只懂得抄书,要学会自己分析问题。

struct student *del(struct student *head,long num)
{
struct student *p1,*p2;
if(head==NULL){printf("\nlist NULL!"); goto end;}
p1=head;
while(num!=p1->num&&p1->next!=NULL)
{
p2=p1;
p1=p1->next;
}
if(num==p1->num)
{
if(p1==head)head=p1->next;
else p2->next=p1->next;
printf("delete:%ld\n",num);
n=n-1;
}
else printf("%ld not been found! \n",num);
end: //////////这里应该用冒号,end是一个标号~
return(head);
}

//////////////////////////////////////////////////
//我自己假设的东西
#include<stdio.h>
#define NULL 0

struct student
{
struct student *next;
int num;
};
//我自己假设的东西
//////////////////////////////////////////////////

struct student *del(struct student *head,long num)
{
struct stude