結構體數組的定義

原文鏈接:https://www.jianshu.com/p/f0088c44a0de

1、先定義結構體類型,再定義結構體數組

struct student 
{
    int num;
    char name[20];
    char sex;
    int age;
};
struct student stu[2];

2、定義結構體類型的同時定義結構體數組

struct student 
{
    int num;
    char name[20];
    char sex;
    int age;
}stu[2];

3、省略結構體類型和變量名稱

struct 
{
    int num;
    char name[20];
    char sex;
    int age;
}stu[2];

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章