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,
Don't use strtok()
for this, since that's not what it's for.
Use strchr()
to find the first separator, and go from there:
char a[] = "A,B,C,D,E";
const char separator = ',';
char * const sep_at = strchr(a, separator);
if(sep_at != NULL)
{
*sep_at = '\0'; /* overwrite first separator, creating two strings. */
printf("first part: '%s'\nsecond part: '%s'\n", a, sep_at + 1);
}