69,373
社区成员
发帖
与我相关
我的任务
分享
//method 1
typedef struct m_struct {
int i;
int j;
} m_struct;
m_struct x, y, z;
x.i = 1;
x.j = 2;
y.i = 3;
y.j = 4;
//exchange x and y
z = x;
x = y;
y = z;
//method 2
m_struct *px, *py, *pz;
px = malloc(sizeof(m_struct));
py = malloc(sizeof(m_struct));
px->i = 1;
px->j = 2;
py->i = 3;
py->j = 4;
//exchange
pz = px;
px = py;
py = pz;