【发布时间】:2012-06-02 13:08:55
【问题描述】:
我尝试通过不同的方式将数组指针复制到另一个数组指针,但没有成功。 这是我的尝试,以及相关的错误消息。
typedef long int coordinate;
typedef coordinate coordinates[3];
void test(coordinates coord) {
coordinates coord2 = coord; // error: invalid initializer
coordinates coord3;
coord3 = coord; // error: incompatible types when assigning to type ‘coordinates’ from type ‘long int *’
coord3 = (coordinates) coord; // error: cast specifies array type
coord3 = (coordinate[]) coord; // error: cast specifies array type
coord3 = (long int*) coord; // error: incompatible types when assigning to type ‘coordinates’ from type ‘long int *’
}
我知道我可以改用typedef coordinate* coordinates;,但它对我来说不是很明确。
【问题讨论】:
标签: c