I'm trying to break input in five parts using strtok(), with each part separated by colons
ab:c:X:cf:b
However, the user can also choose to not enter anything for some parts of the input
f::V:pq:
Is there a way to account for this using strtok? Here is my code so far but it is not working as intended.
piece = strtok(action_def, ":");
if (piece!=NULL) {
execute
}
piece = strtok(NULL, ":");
if (piece!=NULL) {
execute
}
piece = strtok(NULL, ":");
action_list[action_n]->name = *piece;
piece = strtok(NULL, ":");
if (piece!=NULL) {
execute
}
// last char recorded by fgets is '\n'
piece = strtok(NULL, "\n");
if (piece!=NULL) {
execute
}