

#include<iostream>
using namespace std;
//1.创建学生数据类型:学生包括(姓名,年龄,分数)
#include<string>
struct Student{
string name;
int age;
int score;
}s3;
int main(){
struct Student stuArray[3]={
{"张三",18,100},{"李四",28,99},{"王五",38,66}
};
//3、给结构体数组中的元素赋值
stuArray[2].name="老六";
stuArray[2].age=18;
stuArray[2].score=100;
for(int i=0;i<3;i++){
cout<<stuArray[i].name<<stuArray[i].age<<stuArray[i].score;
}
system("pause");
return 0;
}
#include<iostream>
using namespace std;
#include<string>
struct Student{
string name;
int age;
int score;
}s3;
int

本文深入探讨了C#编程中的结构体数组和结构体指针的使用。通过实例解析了如何操作结构体数组,以及如何通过指针高效地处理结构体数据。同时,讨论了结构体作为值类型在内存管理和性能上的考量,对比了与引用类型的区别。
最低0.47元/天 解锁文章
2773

被折叠的 条评论
为什么被折叠?



