评论

收藏

[C++] c++及结构体数组

编程语言 编程语言 发布于:2021-07-26 15:20 | 阅读数:354 | 评论:0

实例代码:
#include<iostream>
using namespace std;
struct Student
{
string name;
int age;
int score;
};
int main()
{
//创建结构体数组
struct Student stdArray[8] = {
{"zhangsan1",18,20},
{"zhangsan2",18,20},
{"zhangsan3",18,20},
{"zhangsan4",18,20},
{"zhangsan5",18,20},
{"zhangsan6",18,20},
{"zhangsan7",18,20},
{"zhangsan8",18,20}
};
for (int i = 0; i < 8; i++)
{
cout << stdArray[i].name << stdArray[i].age << stdArray[i].score << endl;
}
return 0;
}

关注下面的标签,发现更多相似文章