我有下面兩個爲我的迷宮機器人定義的結構。警告:從不兼容的指針類型(指針和結構)分配
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;
我誤解或失去了一些東西?
'M'的類型是'struct mazecells **',而不是'char **'。 – BLUEPIXY
你有沒有讀過[this](http://stackoverflow.com/questions/5491704/is-it-possible-to-cast-a-char-to-a-struct)? – tijko
'mazeValue'的類型爲'char **';你將它分配給'struct mazecells **'類型的變量。 – kfx