Seg Fault in Knowledge Tree

后端 未结 3 501
北荒
北荒 2021-01-28 13:16

I am implementing a knowledge tree in c that can read from a file. I am getting a seg fault in my newStr function. I\'m not able to test the rest of my code with this problem. I

3条回答
  •  灰色年华
    2021-01-28 13:46

    "+" operator as string concatenation does not work in c.

    If you actually want to copy the a string use strdup(). This function allocates memory and copies the string into it.

    Don't forget to free the allocated memory when done using it.

提交回复
热议问题