Quantcast
Channel: Active questions tagged gcc - Stack Overflow
Viewing all articles
Browse latest Browse all 22011

issue with assignment operator inside printf()

$
0
0

Here is the code

int main()
{
  int x=15;
  printf("%d %d %d %d",x=1,x<20,x*1,x>10);
  return 0;
}

And output is 1 1 1 1

I was expecting 1 1 15 1 as output,

x*1 equals to 15 but here x*1 is 1 , Why ? Using assignment operator or modifying value inside printf() results in undefined behaviour?


Viewing all articles
Browse latest Browse all 22011

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>