I am writing some code where I need to use two variables in a for
loop. Does the below code seem alright?
It does give me the expected result.
for (loop_1 = offset,loop_2 = (offset + 2); loop_1 >= (offset - 190),loop_2 <= (190 + offset + 2); loop_1--,loop_2++)
{
if ( (*(uint8_t*)(in_payload + loop_1) == get_a1_byte(bitslip)) &&
((*(uint8_t*)(in_payload + loop_2) == get_a2_byte(bitslip)))
)
{
a1_count++;
}
}
But I am getting a compiler warning which says:
file.c:499:73: warning: left-hand operand of comma expression has no effect
What does this mean?
Best Answer
The problem is the test condition:
This does not check both parts. (Well, it does, but only the result of the second part is used.)
Change it to
if you want both conditions to be checked.