Back to General discussions forum
Hey! I'm having a problem in an if statement. It seems to be ignoring all other conditions other than string[j] != ' ';
//Here is the problem! It ignores all other conditions, and if I take them away(other them != ' ', it works
if(string[j] != ' ' || string[j] != ',' || string[j] != '!' || string[j] != '-') {
aux[count++] = tolower(string[j]);
}
Thanks for your help!
Victor, Hi!
The problem is not in the code, but in the logic which you invented. You say
if character is not space OR is not comma OR...
But it is true for any character. If it is not space then c != ' '
is true, but if it is space, then c != ','
is true. So your condition is always true, that's how OR
works.
I leave this to figure out further to yourself, if you don't mind :)
Ohh! I see now! Thank you very much for your help! Submitted it now and it worked! Thank you, Rodion!