Removing substring from a string?

后端 未结 4 1325
予麋鹿
予麋鹿 2020-12-06 11:08

I have a C function, which takes a string called \'buffer\', and parses it, it will match keywords and use that to assign values in a structure.

However, some keywor

4条回答
  •  囚心锁ツ
    2020-12-06 11:40

    have a look at a simple ANSI C solution like:

    void removeSubstring(char *s,const char *toremove)
    {
      while( s=strstr(s,toremove) )
        memmove(s,s+strlen(toremove),1+strlen(s+strlen(toremove)));
    }
    

提交回复
热议问题