1
int main()
{
int arr[][3]={{1,2},{3,4},{4,5}};
int (*p)[3];
p=arr;
cout<<sizeof(p)<<" "<<sizeof(*p);
return 0;
}

Above is my code,the output of this code is 4 12.So my doubt is what do the complier interpret p and *p as ? what they are actually pointing to?

1 Answer 1

1

P is a pointer, you probably have a 32-bit system, therefore sizeof(p) returns 4. Then you defined p as a pointer to an array of 3 ints, the sizeof int is 4, so the sizeof what it's pointing to, sizeof(*p) is 12.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.