how to make this piece of code work in C++?
- by cambr
#include<stdio.h>
void print(int *arr[], int s1, int s2) {
int i, j;
printf("\n");
for(i = 0; i<s1; i++) {
for(j = 0; j<s2; j++) {
printf("%d, ", *((arr+i)+j));
}
}
printf("\n");
}
int main() {
int a[4][4] = {{0}};
print(a,4,4);
}
This works in C, but not in C++.
error:
cannot convert `int (*)[4]' to `int**' for argument `1' to
`void print(int**, int, int)'
Why does it not work in C++? What change is needed to be made?