C : Value escapes local scope?

前端 未结 1 478
抹茶落季
抹茶落季 2021-02-08 21:34

So I have the following toString function:

/*
 * Function: toString
 * Description: traduces transaction to a readable format
 * Returns: string representing tr         


        
相关标签:
1条回答
  • 2021-02-08 22:21

    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.

    0 讨论(0)
提交回复
热议问题