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

后端 未结 6 1784
名媛妹妹
名媛妹妹 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:31

    If using strtok is not a requirement, you can use strchr instead since the separator is a single character:

    char a[] = "A,B,C,D,E";
    char *sep = strchr(a, ',');
    *sep = '\0';
    puts(a);
    puts(sep + 1);
    

提交回复
热议问题