0

I have a function that use a string x , and at the end of that function I return &x[0] i have this warning warning: address of stack memory associated with local variable 'x' returned [-Wreturn-stack-address]. How can I fix this ? Thank you

kr4t0s26
  • 21
  • 4
  • Don't return the address of something that will cease to exist when the function ends. It's hard to say more with such minimal information provided. – chris May 23 '21 at 19:16
  • You need to show what exactly your function does so we can think up a possible solution to the problem. As for the reason of the warning, it's pretty self-explanatory: `x` will be destroyed when the function ends so the address is invalid. – mediocrevegetable1 May 23 '21 at 19:16

0 Answers0