Returning local array only

sir when i write the code for returning local array then i do not get the address second time inside main function. that is when i write cout<<b<<endl; then instead of getting 0x61fecc as address i get a 0. why is it so?

i am also sending u the ss of my code nd output screen

Hi Pushkar, we return address of a local variable which is not advised as local variables may not exist in memory after function call is over .
So you may use static array or dynamic memory allocation.

1 Like

ok thank u @mayankA47 sir