#include <iostream>
#include <string>
using namespace std;
//学生结构体
struct student {
string name;
int score{};
};
//老师结构体
struct teacher {
string name;
student stu_arr[5];
};
//assignment function
void assign(teacher* p, string tch_name[3], string stu_name[3][5], int scores[3][5])
{
for (int i = 0; i < 3; i++)
{
p->name = tch_name[i];
for (int j = 0; j < 5; j++)
{
p->stu_arr[j].name = stu_name[i][j];
p->stu_arr[j].score = scores[i][j];
}
}
return;
}
int main()
{
teacher tch_arr[3];
//teacher* p[3];
//p[0] = &tch_arr[0];
//p[1] = &tch_arr[1];
//p[2] = &tch_arr[2];
//assignment
string tch_name[3] = { "老李","老王","老张" };
string stu_name[3][5] =
{
{ "1张三","1李四","1王五","1赵六","1周七" },
{ "2张三","2李四","2王五","2赵六","2周七" },
{ "3张三","3李四","3王五","3赵六","3周七" }
};
int scores[3][5] =
{
{ 50, 60, 70, 80, 90 },
{ 78, 97, 55, 65, 85 },
{ 85, 62, 43, 66, 90 }
};
assign(tch_arr, tch_name, stu_name, scores);
for (int i = 0; i < 3; i++)
{
cout << tch_arr[i].name << "老师的学生成绩如下:" << endl;
for (int j = 0; j < 5; j++)
{
cout << tch_arr[i].stu_arr[j].name << ": " << tch_arr[i].stu_arr[j].score << "\t";
}
cout << endl;
}
system("pause");
return 0;
}
// MEMBER FUNCTIONS FOR _Container_base12
_CONSTEXPR20_CONTAINER void _Container_base12::_Orphan_all_unlocked() noexcept {
for (auto& _Pnext = _Myproxy->_Myfirstiter; _Pnext; _Pnext = _Pnext->_Mynextiter) { // TRANSITION, VSO-1269037
_Pnext->_Myproxy = nullptr;
}
_Myproxy->_Myfirstiter = nullptr;
}
代码功能为:assign函数通过结构体指针为主函数中结构体赋值。 出现错误提示:引发了异常: 读取访问权限冲突。 **_Pnext** 是 0xFF
- 写回答
- 好问题 0 提建议
- 追加酬金
- 关注问题
- 邀请回答
-
1条回答 默认 最新
- 技术专家团-Plio大咸鱼 2021-09-30 16:25关注
用malloc申请出一片空间赋值给tch_arr,大小为结构体大小乘结构体个数
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 1无用
悬赏问题
- ¥15 mmocr的训练错误,结果全为0
- ¥15 python的qt5界面
- ¥15 无线电能传输系统MATLAB仿真问题
- ¥50 如何用脚本实现输入法的热键设置
- ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
- ¥30 深度学习,前后端连接
- ¥15 孟德尔随机化结果不一致
- ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
- ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
- ¥15 谁有desed数据集呀