| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 408 人关注过本帖, 1 人收藏
标题:帮我看看错在哪里
只看楼主 加入收藏
studythec
Rank: 1
来 自:安徽阜阳
等 级:新手上路
帖 子:31
专家分:5
注 册:2010-3-13
结帖率:100%
收藏(1)
已结贴  问题点数:20 回复次数:3 
帮我看看错在哪里
想建立一单链表   
提示的信息为:
             fatal error C1903: unable to recover from previous error(s); stopping compilation
#include<iostream>
#include<string>
using namespace std;
struct stu
{
    int num;
    stu *next;
};
void main()
{
    stu H=Null;
    stu *s;
    int x;
    cin>>x;
    while(x!=NULL)
    {
        s=malloc(sizeof(Lnode));
        s->num=x;
        s->next=H;
        H=s;
        cin>>x;
    }
    while(H!=NULL)
    {
        cout<<H->num" ";
        H=H->next;
    }
    cout<<endl;
}
找半天没找到错在哪
搜索更多相关主题的帖子: next void previous include 
2010-03-24 21:06
studythec
Rank: 1
来 自:安徽阜阳
等 级:新手上路
帖 子:31
专家分:5
注 册:2010-3-13
收藏
得分:0 
stu H=Null;程序中是stu *H=NULL;

菜鸟一个,在校学习,多多指教!
2010-03-24 21:19
hziee
Rank: 4
等 级:业余侠客
帖 子:64
专家分:257
注 册:2010-3-12
收藏
得分:10 
#include<iostream>
#include<string>
using namespace std;
struct stu
{
    int num;
    stu *next;
};
void main()
{
    stu H=Null;//stu *H=NULL 大写NULL
    stu *s;
    int x;
    cin>>x;
    while(x!=NULL)
    {
        s=malloc(sizeof(Lnode)); //改为:s=(stu*)malloc(sizeof(stu))
        s->num=x;
        s->next=H;
        H=s;
        cin>>x;
    }
    while(H!=NULL)
    {
        cout<<H->num" "; //cout<<H->num<<endl;
        H=H->next;
    }
    cout<<endl;
    free(s);这个不要忘记
}


[ 本帖最后由 hziee 于 2010-3-24 23:08 编辑 ]
2010-03-24 22:31
赤那
Rank: 3Rank: 3
来 自:广东
等 级:论坛游侠
威 望:1
帖 子:127
专家分:178
注 册:2010-3-1
收藏
得分:10 
#include<iostream.h>
#include<string.h>
#include<stdlib.h>

struct stu
{
    int num;
    stu *next;
};
void main()
{
    stu *H=NULL;
    stu *s;
    int x;
    cin>>x;
    while(x!=NULL)
    {
        s=(stu*)malloc(sizeof(stu));
        s->num=x;
        s->next=H;
        H=s;
        cin>>x;
    }
    while(H!=NULL)
    {
        cout<<H->num<<endl;
        H=H->next;
    }
    cout<<endl;
    free(s);
}
2010-03-24 23:42
快速回复:帮我看看错在哪里
数据加载中...
 
   



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

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