C语言结构体数组

#include <stdio.h>

int main()
{
    /***************************************************
     *结构体数组:数组的每个元素都是结构体类型,注意是同一种结构体类型
     *
     *    struct RankRecord
     *    {
     *       int no;
     *       int score;
     *       char *name;
     *    };
     *    struct RankRecord record[3];
     ****************************************************/

    struct RankRecord
    {
         int no;
         int score;
         char *name;
    };
    struct RankRecord record[3] =
    {
            {1, 90, "zhangsan"},
            {2, 80, "lisi"},
            {3, 100, "wangwu"}
    };
    for (int i=0; i<3; i++)
    {
        printf("record[%d].no = %d, record[%d].score = %d, record[%d].name = %s 
",
                i, record[i].no, i, record[i].score, i, record[i].name);
    }
     return 0;
}
record[0].no = 1, record[0].score = 90, record[0].name = zhangsan 
record[1].no = 2, record[1].score = 80, record[1].name = lisi 
record[2].no = 3, record[2].score = 100, record[2].name = wangwu 
原文地址:https://www.cnblogs.com/heml/p/3530928.html