S is int * , a pointer to an integer, which is the memory address that is on your machine twice as large as an integer.
If you need the size of the array (i.e. the number of elements), you cannot get it directly in pure C. But since this is a C ++ question, there is a way: use vector , which has the size() method.
Actually, this is not entirely true: inside the function that you declare S (and only if it is explicitly initialized at compile time, as in your example, even new int[19] does not work), the sizeof operator really gets the correct answer, therefore C ++ allows you to do this:
int S[]={1,2,3,2,5,6,25,1,6,21,121,36,1,31,1,31,1,661,6}; vector<int> v(S, S + sizeof(S) / sizeof(int) );
and then you can use v.size() (see these docs ).
A version of the Nawaz template elsewhere is another great suggestion that forces the compiler to transfer full information about building a C ++ array (again, note that this is all known at compile time, so you can be explicit about size in the argument).