gpt4 book ai didi

c - 警告 : assignment from incompatible pointer type (Pointers and structures)

转载 作者:太空宇宙 更新时间:2023-11-04 07:01:37 24 4
gpt4 key购买 nike

我为我的迷宫机器人定义了以下两个结构。

struct mazecells{
char type;
int reachable;
int visited;
};

typedef struct maze {
struct mazecells **M;
int startx, starty;
int numrows, numcolumns;
int initdir;
}maze_t;

void ReadMaze(maze_t *maze) {
char **mazeValue;

... remaining declaration and logic ...

mazevalue 中,我已经读取了迷宫输入,然后尝试使用 maze->M = mazeValue 将其分配给您 struct maze_t >。我低于警告:

warning: assignment from incompatible pointer type
maze->M = mazeValue;

我是不是误会了或遗漏了什么?

最佳答案

也许我漏掉了,但你为什么不把 mazeValue 变成 mazecells

struct mazecells{
char type;
int reachable;
int visited;
};

typedef struct maze {
struct mazecells **M;
int startx, starty;
int numrows, numcolumns;
int initdir;
}maze_t;

void ReadMaze(maze_t *maze) {
struct mazecells **mazeValue;

...

关于c - 警告 : assignment from incompatible pointer type (Pointers and structures),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37363182/

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