0
People how to scan a string every 3 characters?
I was doing like this
for(x=0;str_P[x];x++){
if (str_P[x] == 'ABC'||'abc'){ printf("1,");
}if(str_P[x] == 'CBA'||'cba'){ printf("2,");
}if(str_P[x] == 'BCA'||'bca'){ printf("3,");
}if(str_P[x] == 'ACB'||'acb'){ printf("4,");
}if(str_P[x] == 'CAB'||'cab'){ printf("5,");
}if(str_P[x] == 'BAC'||'bac'){ printf("6,");
}
But I got this mistake
multi-character character constant [-Werror,-Wmultichar]
if(str_P[x] == 'ABC'||'abc'){ printf("1,");
^
multi-character character constant [-Werror,-Wmultichar]
if(str_P[x] == 'ABC'||'abc'){ printf("1,");
^
error: use of logical '||' with constant operand
[-Werror,-Wconstant-logical-operand]
if(str_P[x] == 'ABC'||'abc'){ printf("1,");
^ ~~~~~
note: use '|' for a bitwise operation
if(str_P[x] == 'ABC'||'abc'){ printf("1,");
^~~~~~~
|
Formatting both the question with answer is done with Markdown. Read Help with Markdown
– Augusto Vasques
The error is trying to make two simultaneous comparisons using the operator
||
instr_P[x] == 'ABC'||'abc'
. You do something like this:(str_P[x] == 'ABC') || (str_P[x] == 'abc')
in all expressions.– Augusto Vasques
https://i.stack.Imgur.com/7g02T.png
– Axion Ions
if ((str_P[x] == 'ABC') || (str_P[x] == 'abc')){}
– Augusto Vasques
C pira that tmb tried so! (https://i.stack.Imgur.com/D0azg.png)
– Axion Ions