Passed array inconsistent bahevior; C++ -


this question has answer here:

i'm trying learn basic c++ , moment started think got grasp of pointers stumbled across problem:

int sizeof(string texts[]) {     return sizeof(texts); }  int main() {     string texts[] = {"apple", "banana", "orange", "watermelon"};     cout << sizeof(texts) << endl;     cout << sizeof(texts) << endl; } 

and function returns

128 8 

my question is: happening when pass array argument? why c++ forgets array? have tried dereference inside method (return sizeof(*texts)) returned 32 instead size of 1 string element, not whole array. possible want do? mistaken?


Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -