Your *
token is likely also containing the \n
character you typed to complete your input. Either compare a single character with one of:
if(tok[0] == '*')
if(strncmp(tok, "*", 1) == 0)
or add \n
to your separator list:
tok = strtok(NULL, " \n");