完整代码:
#include <stdio.h>
int main (void)
{
struct list
{
int ranking;
char *name;
int score;
};
struct list lists[3]={
{1,"xie",5000}, //此处是用逗号","隔开
{2,"li",4000},
{3,"xu",3000},
};
for (int i=0; i<3; i++)
{
printf ("%d\t %s\t %d\n",lists[i]);//这种写法也正确,暂时不知道原因
printf ("%d\t %s\t %d\n",lists[i].ranking,lists[i].name,lists[i].score);
}
return 0;
} |