My if statement has two conditions, as follows:
if((strcasecmp(&word[0], &j) == 0) && (strlen(word) == i))
If the condition contains only one of these two, that is,
if(strcasecmp(&word[0], &j) == 0)
or
if(strlen(word) == i)
it returns true when either of the two conditions are run, so they are both true separately. However, when I put them together like this, it returns false.
The statement is inside two nested for loops, as follows:
for(int i = 0; i < LENGTH; i++)
{
for(char j = 'a'; j <= 'z'; j++)
{
if((strcasecmp(&word[0], &j) == 0) && (strlen(word) == i))
{
//code here
}
}
}
(word is a const char *, length is a constant defined as 45).
Anyone know why this is happening?
Aucun commentaire:
Enregistrer un commentaire