我试图创建一个函数来为其他游戏初始化一个板子,我认为使用泛型函数会对学习更好,但是我很早就遇到了问题,有人可以告诉我为什么这不工作? 我定义了一个10x10 int数组的othelotype。C:下标值既不是数组也不是指针
othelotype* inicializartablero (othelotype* board)
{
int x, y;
for (x = 0; x < 8; x++)
for (y = 0; y < 8; y++)
board[x][y] = 2;
board[4][5] = board[5][4] = 0;
board[4][4] = board[5][5] = 1;
}
,你能否告诉我们othelotype'的'的定义是什么? – arshajii 2014-09-21 01:41:42
它是以下的 结构othelotype int cuadrado [10] [10]; } * board2; – 2014-09-21 02:22:36
从变量定义中分离'struct othelotype {...};'通常会更好。另外,当你不需要动态分配时,你可以使用'struct othelotype board',然后将它传递给你的函数'inicializartablero(&booard)'。 – 2014-09-21 07:10:48