C

Asked • 03/26/19

How to find the 'sizeof' (a pointer pointing to an array)?

First off, here is some code: int main() { int days[] = {1,2,3,4,5}; int *ptr = days; printf("%u\\n", sizeof(days)); printf("%u\\n", sizeof(ptr)); return 0; }Is there a way to find out the size of the array that `ptr` is pointing to (instead of just giving its size, which is four bytes on a 32-bit system)?

1 Expert Answer

By:

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.