Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

left-hand operand of comma expression has no effect

Tags:

c

for (count = index, packet_no = 0; 
     count < TOTAL_OBJ, packet_no < TOTAL_PKT; 
     count++, packet_no++)

=> left-hand operand of comma expression has no effect.

I find the above code is correct and could not understand why this error comes.

like image 611
Angus Avatar asked Dec 01 '22 04:12

Angus


1 Answers

This is how the comma operator works, what you want to do is to use OR or AND (probably AND in your case):

// the condition for resuming the loop is that one of the conditions is true
count < TOTAL_OBJ || packet_no < TOTAL_PKT
// the condition for resuming the loop is that both conditions are true
count < TOTAL_OBJ && packet_no < TOTAL_PKT
like image 156
MByD Avatar answered Dec 02 '22 19:12

MByD