I have following string:
char str[] = \"A/USING=B)\";
I want to split to get separate A
and B
values with /
See this. I got this when I searched for your question on google.
In your case it will be:
#include
#include
int main (int argc, char* argv [])
{
char theString [16] = "abcd/USING=efgh";
char theCopy [16];
char *token;
strcpy (theCopy, theString);
token = strtok (theCopy, "/USING=");
while (token)
{
printf ("%s\n", token);
token = strtok (NULL, "/USING=");
}
return 0;
}
This uses /USING=
as the delimiter.
The output of this was:
abcd
efgh
If you want to check, you can compile and run it online over here.