敲我的头1小时的中间废弃时,无法找到答案:指针矩阵得到的代码
int *get_possible_moves(int **board, int *w, int *h, int *x, int *y) {
int movespossible=0;
int moveslist[2][8];
//4
if(x + 1 <= w-1 && y + 2 <= h - 1) {
if(board[*(int *)y + 2][*(int *)x + 1] == 0) {
moveslist[movespossible][0] = *(int *)x + 1;
breakpoint-> moveslist[movespossible][1] = *(int *)y + 2;
movespossible++;
}
}
在一个行标breakpoint->我的**被董事会解除引用。任何线索为何如此?没有在内存中使用这个地方的并发线程。另外,我在这条线上根本不使用**板。
//3
if(x + 2 <= w - 1 && y + 1 <= h - 1) {
if(board[*(int *)y + 1][*(int *)x + 2] == 0) {
moveslist[movespossible][0] = *(int *)x + 2;
moveslist[movespossible][1] = *(int *)y + 1;
movespossible++;
}
}
此代码完美无缺地工作。
在此先感谢!
为什么所有不必要的(int *)都强制转换? – 2010-01-27 11:21:59