Quote: "Where should sizeof be located ?"
When I select the text sizeof and right click, I get the option to go to the header file in the list, but not go to definition.
sizeof is a function call.
I added the following to one my init functions in my WIP (please learn how to use the buttons in the 'Post Forum Message' form to bracket your code):
void initialiseButtons()
{
int Size = 16;
int* Array = new int[Size];
unsigned int siz = sizeof Array;
TADisplay::showAGKmessage("sizeof returned %u for Array",siz);
// the rest of the function
}
The TADisplay is a class I created to handle a variety of display things.
The showAGKmessage takes a format string and variables, similar to the NSLog function you are using, and pops up a message.
The message said that the array size was 4. Which is correct because Array (I went with that just to see how the compiler liked it) is an integer pointer, not an actual array. You can treat it as an array once you've assigned values to it, but the actual variable itself is NOT an array, it is a pointer.
And the correct format specifier is '%u' for unsigned int.
I think I misunderstood your first post. But the sizeof returning 4 is correct. If your array was defined as something like 'int Array[16]', then you would get the number of bytes actually used for the array (which happens to be 64, 4*16);
Cheers,
Ancient Lady
AGK Community Tester and AppGameKit Master