C language: How to get the remaining string after using strtok() once

后端 未结 6 1796
名媛妹妹
名媛妹妹 2021-02-13 16:42

My string is \"A,B,C,D,E\"
And the separator is \",\"
How can I get the remaining string after doing strtok() once, that is \"B,C,D,E\"

char a[] = \"A,B,         


        
6条回答
  •  借酒劲吻你
    2021-02-13 17:04

    You can vary the set of delimiters, so simply pass an empty string:

    char a[] = "A,B,C,D,E";
    char * separator = ",";
    char * b = strtok(a, separator);
    printf("b: %s\n", b);
    char * c = strtok(NULL, "");
    printf("c: %s\n", c);
    

提交回复
热议问题