gpt4 book ai didi

c - 在c中如何根据一维数组分配二维数组?

转载 作者:行者123 更新时间:2023-11-30 17:39:28 25 4
gpt4 key购买 nike

所以可以说我有一个像这样的数组

int x1[5] = {0,0,0,3,2};
int x2[5] = {0,0,0,3,2};
int x3[5] = {0,0,0,3,2};
int x4[5] = {0,0,0,3,2};

int listofx[4][5];

我几乎希望 listofx 将每个 x 数组存储在其位置之一,当我使用 allocate 时,我收到一条错误消息,指出存在不兼容的类型

最佳答案

你可以这样做:

int *px[] = { x1, x2, x3, x4 };

如果您想访问您的号码,请执行以下操作:

px[1][4]; //1 is x2, 0 is x1

关于c - 在c中如何根据一维数组分配二维数组?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21801835/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com