You just need to call something like strtok(string, "\\")
.
To get the third word, you'll have to call strtok
three times:
#include <stdio.h>
#include <string.h>
int main()
{
char string[] = "abc\\asd\\zxc\\12as";
char *firstword = strtok(string, "\\");
char *secondword = strtok(NULL, "\\");
char *thirdword = strtok(NULL, "\\");
printf("%s\n", thirdword);
}
Also, if you have any control over the data in this situation, you might want to choose a different delimiter character, since \
is going to be eternally inconvenient. Could you use |
instead?