| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 2174 人关注过本帖
标题:关于格雷码的c语言实现 error C2071: 'main' : illegal storage class
只看楼主 加入收藏
whw055670
Rank: 2
来 自:云南昆明
等 级:论坛游民
帖 子:12
专家分:10
注 册:2010-10-29
结帖率:50%
收藏
已结贴  问题点数:10 回复次数:5 
关于格雷码的c语言实现 error C2071: 'main' : illegal storage class
#include <stdio.h>
#include<malloc.h>
#define len sizeof(struct Dulnode)
#define null 0;
typedef struct Dulnode{
 int e;
struct Dulnode *next;
struct Dulnode *front;
}

 main()
{    int i;
    struct Dulnode e;
    struct Dulnode *p;
    struct Dulnode *p1,*p2;
    p=(struct Dulnode*)malloc(len);
    p->next=null;
    p->front=null;
    p1=p;
    p2=p;
    scanf("%d",&p->e);
    for(i=0;i<10;i++){
    while(e==0||e==1)
    {
        p1=(struct Dulnode *)malloc(len);
        scanf("%d",&p1->e);
        p1->next=null;p2->next=p1;
        p1->front=p2;
    };
    p2=p2->next;
    p=p->next;

    };
   
    while(p!=null){
    if(p->e==p->front->e)
        p->e=0;
    else p->e=1;
    p=p->front;};
    for(;p!=null;p=p->next)
    printf("%d",p->e);


error C2071: 'main' : illegal storage class
搜索更多相关主题的帖子: storage c语言 main illegal 
2010-11-23 21:10
whw055670
Rank: 2
来 自:云南昆明
等 级:论坛游民
帖 子:12
专家分:10
注 册:2010-10-29
收藏
得分:0 
大家帮帮忙  上面的程序在编译的时候出现上述的错误.我确实不出错误出在哪里.

大家合作愉快
2010-11-23 21:25
五当家
Rank: 12Rank: 12Rank: 12
等 级:火箭侠
威 望:2
帖 子:1112
专家分:3674
注 册:2010-10-20
收藏
得分:4 
#include <stdio.h>
#include<malloc.h>
#define len sizeof(struct Dulnode)
#define null 0        //这多一个分号;
typedef struct Dulnode
{
    int e;
    struct Dulnode *next;
    struct Dulnode *front;
};
main()
{   
    int i;
    struct Dulnode e;
    struct Dulnode *p;
    struct Dulnode *p1,*p2;
    p=(struct Dulnode*)malloc(len);
    p->next=null;
    p->front=null;
    p1=p;
    p2=p;
    scanf("%d",&p->e);
    for(i=0;i<10;i++)
    {
        while(p->e==0||p->e==1)      //这里是p->e;
        {
            p1=(struct Dulnode *)malloc(len);
            scanf("%d",&p1->e);
            p1->next=null;p2->next=p1;
            p1->front=p2;
        };
        p2=p2->next;
        p=p->next;

    }   
    while(p!=null)
    {
    if(p->e==p->front->e)
        p->e=0;
    else
        p->e=1;
        p=p->front;
    }
    for(;p!=null;p=p->next)
    printf("%d",p->e);

}
差不多就这些了,具体能不能实现你的功能我没看,你自己看看,不行再说.但楼主下次要注意下格式.

经验积累中............
2010-11-23 22:07
huliangmao
Rank: 2
等 级:论坛游民
帖 子:26
专家分:53
注 册:2010-11-17
收藏
得分:4 
我用的codeblocks没有出现编译问题呀
2010-11-23 22:10
五当家
Rank: 12Rank: 12Rank: 12
等 级:火箭侠
威 望:2
帖 子:1112
专家分:3674
注 册:2010-10-20
收藏
得分:0 
typedef struct Dulnode
{
    int e;
    struct Dulnode *next;
    struct Dulnode *front;
};
在定义结构体时后面 }要加分号,但在函数的 }后面不要加分号的.

经验积累中............
2010-11-23 22:11
whw055670
Rank: 2
来 自:云南昆明
等 级:论坛游民
帖 子:12
专家分:10
注 册:2010-10-29
收藏
得分:0 
图片附件: 游客没有浏览图片的权限,请 登录注册

 在调试时候出现这个错误.是怎么回事??

大家合作愉快
2010-11-25 18:37
快速回复:关于格雷码的c语言实现 error C2071: 'main' : illegal storage class
数据加载中...
 
   



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

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