when I'm finding the length of an array, it keeps returning 2 if it is used in a seperate function. If i find the length in the main function however, it finds the length properly. If anyone can help, thank you so much. I'm a c++ noob
void printLength(int inputArray[]) {
cout << "This is my value when finding the length in ANOTHER function: " << sizeof(inputArray)/sizeof(int) << endl;
}
int main()
{
int testArray[] = { 1, 2, 3, 4, 5, 6 };
printLength(testArray);
cout << "This is my value when finding the length in the main function: " << sizeof(testArray)/sizeof(int) << endl;
}
This is my output
This is my value when finding the length in ANOTHER function: 2
This is my value when finding the length in the main function: 6