I am trying to parse the following string:
"USBSTOR\DISK&VEN_JETFLASH&PROD_TRANSCEND_8GB&REV_1100\00H8096XQ9UW1BQ5&0:JetFlash Transcend 8GB USB Device"
based on '\'
(character)
Prob 1: but this character is considered as escape character
Prob 2: \0
in the mid of the string is considered as the end of the string.
I tried so many ways.
(i) I tried to replace '\'
with another character like '$'
and tried to parse with sscanf()
but it did not work.
Can you people suggest something?
#include <string.h>
#include <stdio.h>
int main()
{
char str[80] = "This is \www.tutorialspoint.com \website";
const char s[2] = "\\";
char *token;
/* get the first token */
token = strtok(str, s);
/* walk through other tokens */
while( token != NULL )
{
printf( " %s\n", token );
token = strtok(NULL, s);
}
return(0);
}