strcat implementation

前端 未结 5 1153
暖寄归人
暖寄归人 2020-12-15 00:22

I tried to implement the strcat by myself, and I found the strcat implementation from Wiki like this......but when I use it, there is segmentation fault.

What\'s wro

5条回答
  •  隐瞒了意图╮
    2020-12-15 01:28

    dest needs to have enough memory to accommodate the concatenation in this implementation. In this implementation, it would have to be allocated by the caller. You should also be sure both dest and src are null terminated. If dest does not have enough memory, this will overwrite memory that could be used by something else.

提交回复
热议问题