Still just the size of a pointer there. Note that you got the [] in the wrong place though. In C++ it comes after the variable name.
The bit of knowledge that you are lacking which would enable you to work out why it is like this, and answer the question for yourself, is that sizeof gets replaced with a single number at compile time. That clearly demonstrates how neither checkSize function case could result in returning the size of the array whose pointer was passed in, because there is no way for this function to return anything but the same value every time.
Then if you think about how it is used in main (which incidentally must return int, not void) The array that you are using it on can only be of one size, so you get that array's size no problem.
Show differencesHistory of post edits
#1iMalc
Posted 21 July 2012 - 04:25 PM
Still just the size of a pointer there. Note that you got the [] in the wrong place though. In C++ it comes after the variable name.
The bit of knowledge that you are lacking which would enable you to work out why it is like this, and answer the question for yourself, is that sizeof gets replaced with a single number at compile time.
That clearly demonstrates how neither case could result in returning the size of the array whose pointer was passed in, because there is no way for this function to return anything but the same value every time.
Then if you think about how it is used in main (which incidentally must return int, not void) The array that you are using it on can only be of one size, so you get that array's size no problem.
The bit of knowledge that you are lacking which would enable you to work out why it is like this, and answer the question for yourself, is that sizeof gets replaced with a single number at compile time.
That clearly demonstrates how neither case could result in returning the size of the array whose pointer was passed in, because there is no way for this function to return anything but the same value every time.
Then if you think about how it is used in main (which incidentally must return int, not void) The array that you are using it on can only be of one size, so you get that array's size no problem.