Question about const string array size

Hello, I got an interesting result in counting the size of const string array. Looks the sizeof returns different value in main and sub-function. Could somebody help? In main, it returns the correct value of 140. However, if return from function, it is always 4.

#include <iostream>
#include <string>
#include <vector>
using namespace std;
int stringarraylength(const string array[])
{
return sizeof(array);
}
int main()
{
const string people[5] = { "Tom", "Zoe", "David", "John", "Sam" };
cout << "Size of array: " << stringarraylength(people) << endl;
cout << "Size of array: " << sizeof(people) << endl;
cin.get();
return 0;
}
Here array is pointer! Not array of strings.
So size of pointer it is returning.
Topic archived. No new replies allowed.