I have a function in which i need to pass as argument an integer array. But how can I know the size of the integer array once this is inside the function?
For example, the following code:
void foo(unsigned *p)
{
cout << sizeof(p)/4 << '\n';
}
int main (int argc, const char * argv[]) {
unsigned p[] = {1,2,3,4,5,6,7,8,9,0};
foo(p);
return 0;
Will have as a result the number 1. If I try to use the sizeof operator in the main(), it will have the expected results, however, once the pointer of the array is passed as an argument, it seems I cannot use the sizeof operator.
Any ideas?