So, after some searching and googling, i can not figure out how to extract a value between two tokens in a char array. here is some of my code:
char *data= (char *) malloc( 50);
strcpy(data, "123 123 123 abcdef/456->ghijklm/789 123 123");
I need to extract "abcdef" as Str1 and "ghijkm" as Str2.
The first solution that everyone recommend is strtok as follow:
str1 = strtok(temp, "/"); // str1=abcdef
but how about the secound one? i mean str2, so.
Q1: How do i extract ghijkmn as str2?
Q2: Is there any other existing utility function I can leverage? or any other solution to deal with this kind of situation?
[Added:] What i need is all of strings separated by white spaces. all of "123"s are in desired format except that one is different. I need only two part of it as mentioned above.
newkeyword, which is C++ only."abcdef"? It is clearly not space, because space marks the beginning of string '"123"'. On what basis should we skip over"123", and only match"abcdef"?"123". So (again), how are you saying the expected result is"abcdef"? Or maybe you want the first 3 strings skipped? Or maybe you want the first string that ends with a"/"? You have not been clear.