相关疑难解决方法(0)

不能将一个数组分配给另一个

我尝试通过不同的方式将一个数组指针复制到另一个数组指针,但没有成功。这是我的尝试,以及相关的错误消息。

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 *’
}
Run Code Online (Sandbox Code Playgroud)

我知道我可以使用 …

c

5
推荐指数
1
解决办法
1270
查看次数

标签 统计

c ×1