CodePudding user response:
Add a display conversion - before braces (person), if not support, in the tools - compile options, compile or link command, add open or C11 C99 standard, such as - STD=C11CodePudding user response:
The person x [3]={{xx, xx, xx, xx},{xx, xx, xx, xx},
{xx, xx, xx, xx}.};
It can be initialized
CodePudding user response:
Assignment problem, such assignment is generally at the time of initialization, or a member of the structure need a structure member assignment;Person x [3]={{}, {}, {}};
The initialization of the three members together;
Or
X [0]. Num=1;
Strcpy (x [0]. The name "Alice");
.
The same as below
CodePudding user response:
I can't write this assignment in the image, the initialization can use it only when,Written
Person x [3]={{... }, {... }, {... }};
. Is [0], x x [1], [2] x content, so give it a try
CodePudding user response:
Reference:typedef struct Person {
Int num.
Char name [20].
Int sex;
Char group;
Int score1.
Int score2;
Int score3;
} person;
Int main (int arg c, char * argv [])
{
The person x [3]={
{1, "Alice", 0, 'A', 90,77,95},
{2, "Tony", 1, 'B', 92,78,93},
{3, "Tom", 1, 'C', 87,90,78}
};
int i;
for(i=0; i<3; I++)
Printf (" % d % s c % d % d % d % d % \ n ", x [I] num, x [I]. Name, x [I] sex, x [I] group, x [I] score1, x [I] score2, x [I] score3);
system("pause");
return 0;
}