When I wish to slice a row from a 2-D array in c I can do the following:
void PrintArray(int *arr, int arr_size);
int main(){
int arr[4][4] = {
{10, 13, 56, 66},
{23, 57, 59, 67},
{36, 70, 74, 75},
{40, 75, 80, 91}
};
PrintArray(arr[2], 4);
return 0;
}
void PrintArray(int *arr, int arr_size) {
int i;
for (i = 0; i < arr_size; i++) {
printf("%d ", arr[i]);
}
printf("\n");
}
Which prints:
36 70 74 75
I was wondering if it's possible to do the same column-wise in some elegant/efficient way.
I could transpose the matrix and do the same but it so cumbersome to do it that way.
Note:
I suspect that it might not be possible, but I was wondering if there is a more educated answer to whether it's possible or not.