我尝试过多种方法将一个数组指针复制到另一个数组中,但都没有成功。以下是我的尝试及相应的错误信息。
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;
,但对我来说它不够明确。