| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 480 人关注过本帖
标题:链表在输出的时候系统要求停止
取消只看楼主 加入收藏
yuanhaitaozz
Rank: 1
来 自:江苏
等 级:新手上路
帖 子:32
专家分:9
注 册:2013-8-22
结帖率:100%
收藏
已结贴  问题点数:10 回复次数:2 
链表在输出的时候系统要求停止
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
struct S
{
    char name[20];
    int number;
    struct S *next;
};
int main()
{
    struct S *head=NULL;
    struct S *current,*prev;
    char input[20];
    puts("Enter your name");
    while(gets(input)!=NULL && input[0]!='\0')
    {
        current=(struct S *)malloc(sizeof(struct S));
        if(head==NULL)
            head=current;
        else
            prev->next=current;
        strcpy(current->name,input);
        puts("Enter your number");
        scanf("%d",&current->number);
        while(getchar()!='\n')
            continue;
        puts("Enter next student");
        prev=current;
    }
    if(head==NULL)
        puts("no date");
    else
        puts("now output the contents");
    current=head;
    while(current!=NULL)
    {
        printf("name : %s  number : %d\n",current->name,current->number);
        current=current->next;
    }
    current=head;
    while(current!=NULL)
    {
        free(current);
        current=current->next;
    }
    return 0;
}
为什么在输出的时候系统要求停止呢  我有尝试把输出的语句删去就不会提示  
我就想问下是什么原因
在用vc6.0
搜索更多相关主题的帖子: current include number Enter 
2013-08-26 16:53
yuanhaitaozz
Rank: 1
来 自:江苏
等 级:新手上路
帖 子:32
专家分:9
注 册:2013-8-22
收藏
得分:0 
回复 2楼 liufashuai
我试了一下你说的 还是提示停止工作  然后我干脆不释放删了那句话。。。还是不行
2013-08-26 20:01
yuanhaitaozz
Rank: 1
来 自:江苏
等 级:新手上路
帖 子:32
专家分:9
注 册:2013-8-22
收藏
得分:0 
回复 4楼 liufashuai
  谢了  正如你所说的
2013-08-27 14:39
快速回复:链表在输出的时候系统要求停止
数据加载中...
 
   



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

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