标题:求高手看一看这个程序,有关结构体的。哪错了?
取消只看楼主
gaolongtou
Rank: 2
等 级:论坛游民
帖 子:79
专家分:42
注 册:2012-9-25
结帖率:88.89%
 问题点数:0 回复次数:3 
求高手看一看这个程序,有关结构体的。哪错了?
/*
     2012年10月14日15:52:47
     目的:一个令我很蛋疼的结构体程序!
*/

# include <stdio.h>
struct student  
{
    int year;
    float scroe;
    char  name;
    char  sex;
};
void inputstruct (struct student * st1)
{
    printf("请输入年龄: ");
    scanf("%d",&(*st1).year);
    printf("请输入分数: ");
    scanf("%f",&(*st1).scroe);
    printf("请输入姓名: ");
    scanf("%c",&(*st1).name);
    printf("请输入性别: ");
    scanf("%c",&(*st1).sex);
}
void outputstruct (struct student * st2)
{
    printf("年龄是:%d\n",(*st2).year);
    printf("分数是:%f\n",(*st2).scroe);
    printf("姓名是:%c\n",(*st2).name);
    printf("性别是:%c\n",(*st2).sex);
}
int main(void)
{
    struct student st;
    inputstruct(&st);
    outputstruct(&st);
    return 0;
}
/*
    测试结果是:
    ————————————————
        请输入年龄: 20
        请输入分数: 90
        请输入姓名: 请输入性别: m
        年龄是:20
        分数是:90.000000
        姓名是:

        性别是:m
        Press any key to continue
    ————————————————
*/
先谢谢大家啦!
搜索更多相关主题的帖子: 结构体 include void 
2012-10-14 16:00
gaolongtou
Rank: 2
等 级:论坛游民
帖 子:79
专家分:42
注 册:2012-9-25
得分:0 
回复 2楼 cjbs10086
谢谢了。
2012-10-15 08:55
gaolongtou
Rank: 2
等 级:论坛游民
帖 子:79
专家分:42
注 册:2012-9-25
得分:0 
回复 3楼 lz1091914999
受教了,谢谢。
2012-10-15 08:56
gaolongtou
Rank: 2
等 级:论坛游民
帖 子:79
专家分:42
注 册:2012-9-25
得分:0 
回复 楼主 gaolongtou
谢谢修正。
2012-10-15 08:57



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-383171-1-1.html




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

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