I'm wanting the answer to be 3, which works fine when I do int levels = 3; but the size of the DWORD array changes, so I can't keep it like that.
I can use another parameter in the function and manually count them, but I would just like to understand what I'm doing wrong. With that solution though, the single element array worked again, but the three element array didn't.
/e If it helps, gelatine's method returned a value of 1.
I can suspect that you are trying to determine a size of an array that was passed to a function. Arrays are implicitly converted to a pointer to their first element when they are passed to a function as argument. For example
1 2 3 4 5 6 7 8
void f( int a[] )
{
size_t size = sizeof( a ) / sizeof( *a ); // size is equal to 1
}
int a[] = { 1, 2, 3 }; // the size of the arrray is equal to 3
f( a );
Inside f a is a pointer to the first element of an array passed to the function. So you will get 1 if sizeof( int * ) is equal to sizeof( int ).