/home/meurer/src/prog/project01/main.c:75:5: error: variable-sized object may not be initialized
int *(board[game_sz]) = calloc(game_sz, sizeof(int[game_sz]));
^~~
When I've had to do this I made a macro INDEX_2D(n, i, j) = j * n + i or something like that, then I could just do board[INDEX_2D(n, 0, 0)] = 1 and the like
I didn't want to bother with the complexity of arrays of pointers
It's known that calloc is different than malloc in that it initializes the memory allocated. With calloc, the memory is set to zero. With malloc, the memory is not cleared.
So in everyday work, I regard calloc as malloc+memset.
Incidentally, for fun, I wrote the following code for a benchmark.
...
@BernardoMeurer oh, that's different. malloc + memset will of course be slower than calloc. But you're not using memset or any equivalent, so that's not relevant for your code snippet.
I'm just saying you don't need board to be zeroed in this case, not unless you're doing some multithreading nonsense or the like. Not that it really makes a huge difference.
@BernardoMeurer Hmm... that depends on how you count!
In a a way, you are on the digital level of abstraction and he is on the analog level (possibly). Hence, there are so much more degrees of freedom interacting with an analog computing power blasting away anything you're doing :p