is there any convenient way to create a matrix without using malloc? This kind of works:
int *arr2d[3];
int arr0[] = { 0 };
int arr1[] = { 0, 1 };
int arr2[] = { 0, 1, 2 };
arr2d[0] = arr0;
arr2d[1] = arr1;
arr2d[2] = arr2;
printf(%d, arr2d[i][j]);
It doesn't allow you to loop through the values easily as you can't get the size of each subarray as you could using sizeof for arr2d[3][3].
sizeof arr2d[i] / sizeof arr2d[i][0]
Is there any better way to do this?
For reference, here is the same kind of question for C++: