#include <stdio.h>
#include <string.h> /* needed for strtok */
#include <unistd.h>
#include <stdlib.h>
int main(int argc, char **argv) {
char text[10000];
fgets(text, sizeof(text), stdin);
char *t;
int i;
t = strtok(text, "\"\'| ");
for (i=0; t != NULL; i++) {
printf("token %d is \"%s\"\n", i, t);
t = strtok(NULL, "\"\'| ");
}
}
This is part of the code that im trying to make it is supposed to separate tokens
Let's say the input is 'abc' "de f'g" hij| k "lm | no"
The output should be
token 1: "abc"
token 2: "de f'g"
token 3: "hij"
token 4: "|"
token 5: "k"
token 6: "lm | no"
I get something different but close anyway I can change it to this format?