As far as I know, the following code can be used to obtain the length (meaning how many items it contains) of an array (in this example, an integer array):
int arrayOfInt[] = { 10, 20, 30, 40, 50 };
int lenght = sizeof(arrayOfInt) / sizeof(int);
This gives "5" as output, which is correct. However, if i use the same code in a function, it does not work.
int getLenght(int intArray[])
{
return sizeof(intArray) / sizeof(int);
}
lenght = getLenght(arrayOfInt);
Using the function above, i get "1" as output. Which is not correct. Why does this happen? Am i doing something wrong or is it not possible?