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

=>逗号表达式的左侧操作数无效。
我发现上面的代码是正确的,无法理解为什么会出现这个错误。

最佳答案

这就是逗号运算符的工作原理,您要做的是使用OR或AND(可能在您的情况下):

// 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

09-10 05:32
查看更多