|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
#include<stdio.h>
#include<string.h>
struct student
{
char num[];
float height;
float weight;
float score;
};
int main()
{
struct student ip;
strcpy(ip.num,"201400789");
ip.height = 178.5;
ip.weight = 72.25;
ip.score = 60.5;
printf("%s\n%f\n%f\n%f\n",ip.num,ip.height,ip.weight,ip.score);
}
这个结构体成员把char num[];就会提示错误error C2229: struct 'student' has an illegal zero-sized array
但是改为下面这样就没有错误
struct student
{
char num[10];
float height;
float weight;
float score;
};
或者
struct student
{
float height;
float weight;
float score;
char num[];
};
|
|