If I define a 2D array as:
char *tablechar[][2] = {
{"0", "Innova"},
{"2", "Brio" },
{"3", "Alto" },
{"4", "Bolero"},
{"5", "Swift" }
};
and code in the same file as:
printf("Value = %d\n",sizeof(tablechar));
printf("Value = %d\n",sizeof(tablechar[0]));
printf("Num of rows = %d\n",sizeof(tablechar)/sizeof(tablechar[0]));
Output is as expected:
Value = 40
Value = 8
Num of rows = 5
Now, I pass this 2D matrix in a function whose defination is:
void printstuff(char *tab[][2])
{
printf("Value = %d\n",sizeof(tab));
printf("Value = %d\n",sizeof(tab[0]));
printf("Num of rows = %d\n",sizeof(tab)/sizeof(tab[0]));
}
I get the following output:
Value = 4
Value = 8
Num of rows = 0
with a compiler warning in the above function as:
Why is it so that the value of sizeof(tab) and sizeof(tablechar) different?