请大神帮我看看这个代码哪出问题了,万分感谢

#include
#include
using namespace std;
typedef struct
{int pMat;int row,col;}MAT,*pMAT;
void 生成矩阵A(MAT&a)
{
a.pMat=new int[a.row*a.col];
for(int i=0;i<a.row;i++)
{
for(int j=0;j<a.col;j++)
{
*a.pMat=30+i*10+j*3;
a.pMat++;
}
}
}
void 生成矩阵B(MAT&a)
{
a.pMat=new int[a.row*a.col];
for(int i=0;i<a.row;i++)
{
for(int j=0;j<a.col;j++)
{
*a.pMat=30+i*10+j*2;
a.pMat++;
}
}
}
void 显示矩阵(char
str,MAT&a)
{ int i=0;
for(;str[i]!='\0';i++)
cout< for(int i=0;i {
for(int j=0;j {
cout a.pMat++;
}
}
}
void 矩阵相减(MAT&a,MAT&b,pMAT c)
{
c->pMat=new int[3*4];
for(int i=0;i {
for(int j=0;j {
*c->pMat=*a.pMat-*b.pMat;
a.pMat++;
b.pMat++;
c->pMat++;
}
}
}
void main()
{
int m=3,n=4;
MAT A={0,m,n}, B={0,m,n};
pMAT C=new MAT;
生成矩阵A(A); 生成矩阵B(B);
矩阵相减(A,B,C);
显示矩阵("A:",A); 显示矩阵("B:",B);
显示矩阵("C=A-B:",*C);
delete A.pMat; delete B.pMat;
delete C->pMat;
system("pause");
}

我表示非常蛋疼的问一句,什么问题?

图片说明

在你的生成矩阵中,定义另一个指针 int *p=a.pMat.之后的也如此。
不要直接用你结构体里面的指针去参与运算,特别是在含有new的时候,可能会内存泄漏。