char* mystr = calloc(25, sizeof(char));
fgets(mystr, 25, stdin); // I enter "6 7 *" in here, without the quotes
char* tok;
tok = strtok(mystr, " ");
while (tok != NULL) {
if(strcmp(tok, "*") == 0)
//It never meets this condition, but I don't understand why
else
//do something else here
tok = strtok(NULL, " ");
}
The problem is that the strcmp(tok, "*")
never returns as being equal, even though tok
reads in the asterisk from the original string. I don't understand why it never meets this condition.