I was browsing for finding a way to find number of rows and columns in of a given matrix without any additional information and I came around this answer.
Given a matrix, find number of rows and columns
This is the code snippet from the second answer of the question above :
int main()
{
float a[9][2]={{0,1},{1,1}};
int row=(sizeof(a)/sizeof(a[0]));
int col=(sizeof(a)/sizeof(a[0][0]))/row;
printf("%d\n",row);
printf("%d\n",col);
return 0;
}
How does the sizeof(a[0]) turns out to be 8? In my understanding the pointers have a generic size of 4 bytes in 32 bit arch and 8 bytes in 64 bit arch. I printed out the sizeof(a[0]) on both the machines and the answer is still 8. Anybody has any clue why?
Edited : I mean to say doesn't a[0] decay into a pointer?