Returning a string from a function in C

前端 未结 7 1105
耶瑟儿~
耶瑟儿~ 2020-12-18 07:28

I have a c function that I want to return a string.

If I print the string before it is returned then I see croc_data_0186.idx

If I try and print the string

7条回答
  •  醉酒成梦
    2020-12-18 07:41

    Line is a local variable and is removed at the end of the function.

    You should use malloc, or strcpy it to a string pointer passed as argument.

提交回复
热议问题