Removing substring from a string?

后端 未结 4 1326
予麋鹿
予麋鹿 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:50

    Have a look at the methods in string.h.

    Example: (and on CodePad)

    #include 
    #include 
    #include 
    
    int main()
    {
        const char * source = "FN;CHARSET=UTF-8:David Celery";
        const char * newBegin = strrchr(source, ':');
        if (!newBegin)
        {
            puts("Error!");
            return -1;
        }
        newBegin++;
        puts(newBegin);
        return 0;
    }
    

提交回复
热议问题