vs code运行代码出现missing braces around initializer,使用vc6.0不报错且正常进行
#include <stdio.h>
#include <string.h>
struct student {
long sno;
char name[10];
float score[3];
};
void fun(struct student a[ ] , int n)
{struct student t; int i, j;
for (i=1; i<n; i++)
for (j=0; j<n-i; j++)
if (strcmp(a[j].name,a[j+1].name) > 0)
{ t = a[j]; a[j] = a[j+1]; a[j+1] = t; } }
int main()
{ struct student s[4]={{10001,"zhang",95,56,41},
{10002,"li",95,65,71},
{10003,"cao",98,65,98},
{10004,"fang",97,95,46}};
int i, j;
fun(s, 4);
for (j=0; j<4; j++)
{ printf("\nNo: %ld Name: %-8s Scores: ",s[j].sno, s[j].name);
for (i=0; i<3; i++)
printf("%6.2f ", s[j].score[i]); }
return 0;
}
运行结果及报错内容
不能运行 missing braces around initializer [-Wmissing-braces]
怎么解决报错问题