#include <stdio.h>
#include <string.h>
int main(void){
char str[] = "V1{V 4.3}-V1{V 3.2}"; /* actual string */
char buff[32] = { 0 }; /* a copy of actual string */
char delim[] = "V"; /* used to specify the substrings */
char* token = NULL; /* used to store substring token from the actual string */
strcpy(buff,str);
token = strtok(buff,delim);
/* (0) output provided data */
if(token != NULL){
printf("\n actual = '%s'\n",str);
printf(" delim = '%s'\n",delim);
}
/* (1) check if delim exists in the actual string */
if(strlen(token) != strlen(str))
printf(" substr = '%s'",token);
else
printf("\n (!) error, couldn't find '%s'\n",delim);
/* (2) proccess each substring if found any, and show it on the screen */
while((token = strtok(NULL,delim)) != NULL){
printf(" '%s'",token);
}
printf("\n");
return 0;
}