Hello everyone. I have a problem using strtok in C. I get a user input from the command line and I want to tokenize it with pipe ("|") as the delimeter and put the result in a double pointer variable. Here's my code:
char** argv;
char *token;
token = strtok(userInput, "|");
while(token != NULL){
*(argv++) = token;
token = strtok(NULL, "|");
}
*argv = '\0';
I then use this code to verify if it's well tokenized
while(*argv!= NULL)
{
if((strcmp(*argv, "|") == 0){
count = count + 1;
}
argv++;
}
printf("%d pipes", count);
But it doesn't work. I can't seem to use strtok. Any ideas please? Thanks