replacing pieces of string

后端 未结 3 1996
星月不相逢
星月不相逢 2021-01-22 18:19

i\'m doing something like excel, i have something like this:

1         2           3
A1        B1          C1

where it replaces the content for

3条回答
  •  走了就别回头了
    2021-01-22 18:47

    Any time you run into some string manipulation problem in C, your first instinct should be to look at string.h and see what's available there. As outlined in several answers here, there is no function to do string replacement directly, but it should be possible to use strstr and strncpy to find occurrences of substrings and then copy the replacement (into a new buffer so as not to clobber the rest of the original, obviously).

提交回复
热议问题