I am trying to write a loop which runs across all the elements in the array. I learned the concept here. I am facing some difficulty with its execution. I have been trying to debug and I have written the following function as part of that debugging process. The following is my code:
#include <iostream>
using namespace std;
struct Vmul {
double c[4][4];
};
double Vmulti(double a[4], double d[4]) {
cout << sizeof(a) << endl;
cout << sizeof(a[0]) << endl;
cout << sizeof(a)/ sizeof(a[0]) << endl;
return 0;
}
int main()
{
double r[4] = { 1,2,3,4 };
double q[4] = { 1,2,3,4 };
Vmulti(r, q);
return 0;
}
Output:
4
8
0
Press any key to continue . . .
I am unable to figure out why sizeof(a) return only 4? shouldn't it be 8*4? why isn't sizeof giving me the size and instead giving me the number of elements in the array?