当前位置: 代码迷 >> C语言 >> vc中的end问题,和删除链表函数
  详细解决方案

vc中的end问题,和删除链表函数

热度:331   发布时间:2008-05-06 19:10:13.0
vc中的end问题,和删除链表函数
在vc中好像用 goto end;不行显示error C2094: label 'end' was undefined
删除链表函数中用到了
而且这个函数好像不大对,
struct student * del(struct student * head, long del_num)
{
    struct student * p1, * p2;
    p1 = p2 = head;
    if(head == NULL)    
    {
        printf("\n链表为空!\n");
        goto end;
    }
        while(p1 -> num != del_num && p1 -> next != NULL);//能不能在这用else改呢????
        {
            p2 = p1;
            p1 = p2 -> next;
        }
            if(p1 -> num == del_num)
            {
                if(head == p1)   head = p1 -> next;
                else
                    p2 -> next = p1 -> next;
                n = n - 1;
                printf("已删除%ld!", del_num);
            }
            else
                printf("无法找到%d元素!", del_num);    
               end;
        return (head);
}
搜索更多相关的解决方案: 链表函数  vc中  end  num  head  

----------------解决方案--------------------------------------------------------
楼主可能还不明白goto语句的用法吧。
看以下程序段:
int i;
scanf("%d",&i);
if(i>0)
  goto i_above_0;
else if(i<0)
  goto i_below_0;
else
  goto end;
i_above_0: printf("i>0\n"); goto end;
i_below_0: printf("i<0\n"); goto end;
end: printf("The end of the program");

goto语句是转移作用,它的转移效率非常高,因为它在编译时直接编译成jmp指令。但建议没有特殊情况下不要使用。
----------------解决方案--------------------------------------------------------
貌似goto极容易造成错误的,上次偶写了段程序,当跳转到 有 输入语句和判断语句的地方时就不运行了 - -!
----------------解决方案--------------------------------------------------------
刚刚看了一下goto
可是运行有错error C2065: 'end' : undeclared identifier
是不是应该定义或把end怎么样呢?
----------------解决方案--------------------------------------------------------
明白了
恩恩
end后面是:号不是;号
----------------解决方案--------------------------------------------------------
  相关解决方案