绝代码农 发表于 2021-7-26 15:20:06

c++及结构体数组

实例代码:
#include<iostream>
using namespace std;
struct Student
{
string name;
int age;
int score;

};

int main()
{
//创建结构体数组
struct Student stdArray = {
{"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.name << stdArray.age << stdArray.score << endl;

}

return 0;
}

文档来源:51CTO技术博客https://blog.51cto.com/u_15286849/3183391
页: [1]
查看完整版本: c++及结构体数组