敲我的頭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