I am having trouble when using a "*" when comparing strings in my C program. Is there some rule that prohibits using it? Here is the troublesome piece of code:
else if(strcmp(argv[i], "*") == 0)
{
printf("pos MULT: %d", pos);
result = dubStack[pos-1] * dubStack[pos - 2];
pos += 1;
}
When running the program with the code above my print statement does not run and the result is not calculated. However if I change the character in the string compare (such as shown below; changed * to an m), the correct operation is performed and the print statement works. Is there something I'm missing when using the * for this?
else if(strcmp(argv[i], "m") == 0)
{
printf("pos MULT: %d", pos);
result = dubStack[pos-1] * dubStack[pos - 2];
pos += 1;
}
Aucun commentaire:
Enregistrer un commentaire