Returning a string from a function in C

前端 未结 7 1103
耶瑟儿~
耶瑟儿~ 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:56

    The problem is that you are returning an stack variable, lost when function returns. One way to make this is to use a char * arg in function parameter, with enough reserved space, and use it to store all information and returns it.

提交回复
热议问题