In your function getSize(), stris a pointer. Therefore sizeof(str)returns the size of the pointer . (in this case, it is 8 bytes)
An main() strarray is in your function . Therefore, it sizeof(str)returns the size of the array .
This is one of the subtle differences between arrays and pointers.
source
share