| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1556 人关注过本帖
标题:vc中的end问题,和删除链表函数
只看楼主 加入收藏
zhzhdwy
Rank: 1
等 级:新手上路
帖 子:11
专家分:0
注 册:2008-4-19
收藏
 问题点数:0 回复次数:4 
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 
2008-05-06 19:10
neverTheSame
Rank: 3Rank: 3
来 自:江西农业大学
等 级:新手上路
威 望:9
帖 子:1511
专家分:0
注 册:2006-11-24
收藏
得分:0 
楼主可能还不明白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指令。但建议没有特殊情况下不要使用。

wap酷禾网(http://wap.),提供免费的、优质的、快捷的wap资源下载服务。
2008-05-06 20:33
feelerly
Rank: 1
来 自:GZ
等 级:新手上路
帖 子:17
专家分:0
注 册:2008-5-1
收藏
得分:0 
貌似goto极容易造成错误的,上次偶写了段程序,当跳转到 有 输入语句和判断语句的地方时就不运行了 - -!
2008-05-06 20:43
zhzhdwy
Rank: 1
等 级:新手上路
帖 子:11
专家分:0
注 册:2008-4-19
收藏
得分:0 
刚刚看了一下goto
可是运行有错error C2065: 'end' : undeclared identifier
是不是应该定义或把end怎么样呢?
2008-05-06 20:46
zhzhdwy
Rank: 1
等 级:新手上路
帖 子:11
专家分:0
注 册:2008-4-19
收藏
得分:0 
明白了
恩恩
end后面是:号不是;号
2008-05-06 20:55
快速回复:vc中的end问题,和删除链表函数
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.021333 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved