C : Value escapes local scope?

久未见 提交于 2019-12-03 06:33:33

You've defined a local variable pointer (edit thanks) inside that function and are trying to return it.

That's a no-no, as the variable's lifetime is only that of it's enclosing scope, here, the function call. Anyone trying to reference the return value will trigger undefined behavior, usually a crash, if you're lucky.

If you want to return the array, you need to pass it in as an argument.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!