Given the following program,
#include
using namespace std;
void foo( char a[100] )
{
cout << \"foo() \" << sizeof( a ) <
There is magnificent word in C/C++ terminology that is used for static arrays and function pointers - decay. Consider the following code:
int intArray[] = {1, 3, 5, 7, 11}; // static array of 5 ints
//...
void f(int a[]) {
// ...
}
// ...
f(intArray); // only pointer to the first array element is passed
int length = sizeof intArray/sizeof(int); // calculate intArray elements quantity (equals 5)
int ptrToIntSize = sizeof(*intArray); // calculate int * size on your system