标题:结构体中一个float型变量初始化问题
取消只看楼主
雨汪
Rank: 1
等 级:新手上路
帖 子:5
专家分:0
注 册:2013-8-2
结帖率:100%
已结贴  问题点数:10 回复次数:0 
结构体中一个float型变量初始化问题
#include<stdio.h>
struct stu
{
    int num;
    char name[20];
    char sex;
    float score;
}boy[5]=
{
    {101,"zhou ping",'M',45},
    {102,"zhang ping",'M',62.5},
    {103,"cheng ling",'F',92.5},
    {104,"wang ming",'M',62.2},    /*出现警告处*/                                 
    {105,"liu fang",'F',62.5}
};
int main()
{
    struct stu *p;
    printf("no\tname\t\t\tsex\tscore\t\n");
    for(p=boy;p<boy+5;p++)
        printf("%d\t%s\t\t%c\t%f\t\n",p->num,p->name,p->sex,p->score);
    return 0;
}
编译时有一个警告,   'initializing' : truncation from 'const double ' to 'float '  把62.2改成其他的数有的可以有的还是不行,各位大神求指教啊!!!
搜索更多相关主题的帖子: 结构体 include zhang cheng 
2013-08-02 15:14



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




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

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