M
mx
Actually, I'm not even sure it's possible to dynamically allocate a
fixed size one dimensional array.
So here's the problem:
I have a type 'board' defined as so:
typedef char board[8][8]
and I am supposed to write a function with the following prototype:
Board *new_board();
which would require me to use malloc for allocation.
I've tried many different things that I'd be ashamed to post here but
have found no solution.
The problem is that it doesn't seem possible to cast a char* or char**
to a fixed length array (e.g. char[8] or char[8][8] or board in this case)
I'll add that this exercise I have been given specifies the 'board' type
and new_board() function exactly as I have said and I would find a
workaround if I had the choice.
fixed size one dimensional array.
So here's the problem:
I have a type 'board' defined as so:
typedef char board[8][8]
and I am supposed to write a function with the following prototype:
Board *new_board();
which would require me to use malloc for allocation.
I've tried many different things that I'd be ashamed to post here but
have found no solution.
The problem is that it doesn't seem possible to cast a char* or char**
to a fixed length array (e.g. char[8] or char[8][8] or board in this case)
I'll add that this exercise I have been given specifies the 'board' type
and new_board() function exactly as I have said and I would find a
workaround if I had the choice.