| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 632 人关注过本帖
标题:这个结构体套用 怎么报错啊?求解
只看楼主 加入收藏
C小菜
Rank: 1
等 级:新手上路
帖 子:109
专家分:3
注 册:2011-9-14
结帖率:66.67%
收藏
 问题点数:0 回复次数:4 
这个结构体套用 怎么报错啊?求解
程序代码:
#include <stdio.h>
#include <stdlib.h>
struct birthday
{
    int year;
    int month;
    int day;
}
struct student
{
    int studentid;
    char name[10];
    char sex;
    struct birthday dob;
    float score;
} a={1,"李四",'m',{1993,12,3},95.5};
int main()
{
    printf("学号:%d\n,姓名:%s\n,性别:%c\n,出生日期%d-%d-%d\n,成绩:%f\n",a.studentid,a.name,a.sex,a.dob.year,a.dob.month,a.dob.day,a.score);
    return 0;
}
搜索更多相关主题的帖子: 结构体 color 
2011-12-05 21:45
Glost
Rank: 2
来 自:湖北
等 级:论坛游民
帖 子:54
专家分:48
注 册:2010-10-5
收藏
得分:0 
太不仔细了吧,少了个“;”,这种问题......

只有一条路不能选择—那就是放弃的路;只有一条路不能拒绝—那就是成长的路。
2011-12-05 21:49
C小菜
Rank: 1
等 级:新手上路
帖 子:109
专家分:3
注 册:2011-9-14
收藏
得分:0 
回复 2楼 Glost
哪里少了个;
2011-12-05 22:06
Glost
Rank: 2
来 自:湖北
等 级:论坛游民
帖 子:54
专家分:48
注 册:2010-10-5
收藏
得分:0 
回复 3楼 C小菜
struct birthday
{
    int year;
    int month;
    int day;
};//这个位置...

只有一条路不能选择—那就是放弃的路;只有一条路不能拒绝—那就是成长的路。
2011-12-05 22:49
原味好
Rank: 4
来 自:西安
等 级:业余侠客
帖 子:59
专家分:250
注 册:2011-11-29
收藏
得分:0 
程序代码:
#include <stdio.h>
#include <stdlib.h>
struct birthday
{
    int year;
    int month;
    int day;
}//这里少了个分号;
struct student
{
    int studentid;
    char name[10];
    char sex;
    struct birthday dob;
    float score;
} a={1,"李四",'m',{1993,12,3},95.5};
int main()
{
    printf("学号:%d\n,姓名:%s\n,性别:%c\n,出生日期%d-%d-%d\n,成绩:%f\n",a.studentid,a.name,a.sex,a.dob.year,a.dob.month,a.dob.day,a.score);//逗号放到\n前面会好看点
    return 0;
}

2011-12-05 22:56
快速回复:这个结构体套用 怎么报错啊?求解
数据加载中...
 
   



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

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