So basically I'm trying to write a method that returns two times the length of an array, but I cannot figure out how to make the length into an int so that it can be used. I have been trying to figure out the correct method to use since sizeof() returns the number of bytes, not the length of the array. What method should I be using and how can I fix this? Here is my code:
int main(int argc, const char * argv[]) {
int arr[] = {1,2,3,4,5};
cout << getLen(arr);
return 0;
}
int getLen( int *arr ){
int len = sizeof(arr);
return 2 * len;
}