本帖最后由 736010695 于 2014-11-21 13:41 编辑
//定义结构体数组
#include <stdio.h> int main() { //定义结构体变量类型 struct rankrecord { int no; char *name; int score; };
//定义结构体变量数组 struct rankrecord records[] = { {1, "jimmy", 500}, {2, "tom", 400}, {3, "cook",300} };
//便利结构体数组里的元素
for(int i = 0, i < 3, i++)
{
printf("%d, %s, %d\n", records.no, records.name, records.score);
}
return 0;
}
|