I'm trying to print the elements of a 2D array but I keep getting a segmentation fault (I use my own printing function so i don't use printf)
the code:
(this is the main)
int main()
{
int zArr[3][4]={1, 2, 3, 4};
int *zPtr = *zArr;
print2dArray(&zPtr, 3, 4);
return 0;
}
(this is the function)
void print2dArray(int **arr, int rows, int cols)
{
int a = 0;
int b = 0;
for(a = 0; a < rows; a++) {
for(b = 0; b < cols; b++) {
putNum(arr[a][b]);
}
}
}
(this is the output)
1
2
3
4
segmentation fault(core dumped)