Removing substring from a string?

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

    Instead of removing them, you could just ignore them, for example like this:

    #define KEY_TO_IGNORE "CHARSET=UTF-8"
    
    char key[80];
    char value[80];
    char *text = "FN;CHARSET=UTF-8:David Celery";
    
    sscanf(text, "%2s;" KEY_TO_IGNORE ":%s", key, value);
    
    printf("key: %s, value: %s\n", key, value);
    

提交回复
热议问题