gpt4 book ai didi

c - 访问二维结构数组上的值

转载 作者:太空宇宙 更新时间:2023-11-03 23:44:55 25 4
gpt4 key购买 nike

所以我有这个结构

struct cell
{
int downwall;
int rightwall;
};

我已经为 struct cell 的二维数组动态分配了内存(构造单元格**数组)

但是当我尝试使用命令访问某个单元格时

array[i][j] -> downwall = 0;

我收到这个错误:

invalid type argument of '->' (have 'struct cell')

最佳答案

使用

array[i][j].downwall = 0;

相反。

如果 arrray[i][j] 有类型 struct cell* 而它没有,你会使用 ->。它的类型为 struct cell

关于c - 访问二维结构数组上的值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35828597/

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