sizeof(arr)
is returning different values from inside main
and in arr_size
. I expect the array to have all the same properties, I tested that the array isn't completely ruined by accessing a value which worked in all scopes, so I'm at a loss.
#include <iostream>
void arr_size(std::string* arr_) {
std::cout << sizeof(arr_) << std::endl; // 8
std::cout << arr[0] << std::endl;
}
int main() {
std::string arr[100] = {};
arr[0] = "iiiiiiiiiiiiiii";
arr_size(arr);
std::cout << sizeof(arr) << std::endl; // 3200
std::cout << arr[0] << std::endl;
}
As it shows: the sizeof()
the array from within arr_size
is 8
, while the expected size given from within main
is 3200
.
Edit, dereferencing arr_
returns the size of std::string, which I would also like to understand.