Assigning value in while loop condition

前端 未结 5 1928
鱼传尺愫
鱼传尺愫 2020-12-25 08:18

I found this piece of code on Wikipedia.

#include 

int main(void)
{
  int c;

  while (c = getchar(), c != EOF && c != \'x\')
  {
           


        
5条回答
  •  难免孤独
    2020-12-25 08:47

    The comma operator is a binary operator that evaluates its first operand and discards the result, it then evaluates the second operand and returns this value.

    It is also a "sequence point", which means that all side effects will be calculated before the next part of the code is executed.

提交回复
热议问题