I'm new to C++ programming and I'm trying to get the size of an array. Can anybody explain me why this happens? I've tried running the code in runnable.com and the same result shows.
I'm sure this is not the right way to do it. If possible, can you suggest any EASY way to get the size of that kind of array?
#include <iostream>
using namespace std;
int main ()
{
int set1[] = {1, 9, 3, 50, 31, 65};
int set234[] = {3, 5, 5};
cout << sizeof(set1) << endl;
cout << sizeof(set234) << endl;
cout << "When sizeof() return value is divided by 4"<< endl;
cout << sizeof(set1) / 4 << endl;
cout << sizeof(set234) / 4 << endl;
return 0;
}
****************************************************************
Output:
24
12
When sizeof() return value is divided by 4
6
3
****************************************************************
**EDIT : Thank you for your responses. flies away :D