I'm trying to write a code which tokenize the string 2 times. In 1st pass it tokenize based on "&" and on second pass it should tokenize based on "|". But after 1st pass, it does not continue. Below is sample code.
#include <iostream>
#include <string.h>
            
using namespace std;
            
int main () {
             
    char value[] = "Hello | my | Name & is | Pratik & lets see";
    char *token = strtok (value, "&");
 
    while (token != NULL) {
        cout << "\n token: " << token;
        char *token_1 = strtok (token, "|");
        while (token_1 != NULL) {
                  
            cout << "\n token_1: " << token_1;
            token_1 = strtok (NULL, "|");
        }
        token = strtok (NULL, "&");
    }
    return 0;
}
I'm getting out put token: Hello | my | Name token_1: Hello token_1: my token_1: Name
I'm I missing anything?
 
     
    