I just want to print out a static array (2D array) in C using functions. I use gcc as my compiler. When I try to run my code it gives me a seg fault and I dont have any idea why:
#include <stdio.h>
void print_out_an_array(int n, int m, int tab[n][m])
{
int i,j;
for(i=0; i<n; i++)
for(j=0; j<m; j++)
printf("tab[%d][%d] = %d\n", i, j, tab[i][j]);
}
int main(int argc, char **argv)
{
int tab[2][4] = {{1,2,3,4}, {5,6,7,8}};
print_out_an_array(tab, 2, 4);
return 0;
}