结构体中一个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改成其他的数有的可以有的还是不行,各位大神求指教啊!!!