I was making a try in passing C++ arrays as arguments in C++ and encountered some problems. I went through this and still wasn't able to solve the problem.
C++ #include<iostream> using namespace std; void comb(int a[]) { int alen = sizeof(a)/sizeof(*a); cout << alen << endl; /* Since 'I' know the size of a[] */ for(int i = 0; i < 7; i++) cout << a[i] << " "; cout << endl; } int main() { int a[] = {1,2,3,4,5,6,7}; comb(a); } Output 2 1 2 3 4 5 6 7 My question is how come the size of the array is getting calculated as 2?
intsizeof(a)/sizeof(a[0])?