#include<iostream>
#include<cstring>
#include<stack>
using namespace std;
typedef struct{
int detail[3][3];
}Map;
int main(){
Map m,n;
//利用指针进行struct结构体中数组的赋值操作
for(int i=0;i<9;i++)
scanf("%d",*m.detail+i);
for(int i=0;i<9;i++)
scanf("%d",*n.detail+i);
for(int i=0;i<9;i++)
printf("%d ",*((*m.detail)+i));
//内存空间数据的直接比较
cout<<memcmp((const void*)(*m.detail),(const void*)(*n.detail),36);
stack<Map> Stack;
Stack.push(m);
Stack.push(n);
return 0;
}
本文介绍了一个使用C++实现的简单示例,包括结构体定义、数组赋值及栈的基本操作。该示例展示了如何通过指针操作结构体中的数组,并使用标准库中的栈来存储和读取结构体变量。
7595

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



