【发布时间】:2012-08-23 19:50:06
【问题描述】:
我正在尝试交换一个结构数组,我认为按照类似的方式存储在 temp 中会像这样工作:
int temp ,a, b;
temp = a;
a = b;
b = temp;
我的结构定义数组是这样的:
struct storage data[10];
我尝试交换一个结构数组,我试过这个:
struct storage temp[1];
temp = data[1];
data[1] = data[2];
data[2] = temp;
不幸的是,它没有编译
我的错误如下:
错误 #2168:“=”的操作数具有不兼容的类型“struct storage[1]”和“struct storage”。
错误 #2088:需要左值。
错误 #2168:“=”的操作数具有不兼容的类型“struct storage”和“struct storage*”。
【问题讨论】: