我写了这个函数来交换多维数组中的值,因为我理解数组是指针。
void
swap(int* a, int* b)
{
int tmp = *a;
*a = *b;
*b = tmp;
}
但是,当我尝试使用该功能时
swap(board[d-1][d-2]), board[d-1][d-33];
我从编译器中得到这些错误,但我不知道为什么:
fifteen.c: in function 'init':
fifteen.c:166:9: error: passing argument 1 of 'swap' makes pointer from integer without a cast [-werror]
fifteen.c:45:6: note: expected 'int *' but argument is of type 'int'
fifteen.c:166:9: error: passing argument 2 of 'swap' makes pointer from integer without a cast [-werror]
fifteen.c:45:6: note: expected 'int *' but argument is of type 'int'
我如何解决它?