Remove a substring in C given positions of substring

后端 未结 5 2041

Let\'s say I have a char *example that contains 20 chars. I want to remove every char from example[5] to example[10] and then fix up the a

5条回答
  •  无人及你
    2021-01-29 00:12

    memmove(&example[5], &example[11], strlen(example) - 11 + 1);
    

    Note that the behavior of memcpy is undefined when the memory blocks overlap, so memmove is more appropriate here.

提交回复
热议问题