for (count = index, packet_no = 0;
count < TOTAL_OBJ, packet_no < TOTAL_PKT;
count++, packet_no++)
=>
逗号表达式的左侧操作数无效。
我发现上面的代码是正确的,但不明白为什么会出现这个错误。
最佳答案
这就是逗号运算符的工作方式,您要做的是使用 OR 或 AND(在您的情况下可能是 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
关于c - 逗号表达式的左侧操作数无效,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13579801/