Hi all.
I have a problem with a pointer and a bidimensional array.
here's the code:
........Code:includes.. typedef char t_board[5][4]; int i,j; t_board *copy (t_board b) { t_board *ptr; ptr = (t_board *) malloc (sizeof(t_board)); for (i=0; i<5; i++) for (j=0; j<4; j++) *ptr[i][j] = b[i][j]; return ptr; } int main () { t_board some_board, *new_board; new_board = copy(some_board); . . code here . . }
After this, I print new_board, and its ok; but the following code after
the call to copy, crashes. Don't know why.
if I remove the statment new_board = copy(some_board); , the code that follows runs ok.
Can someone tell me why?
Thanks;