0

I encountered the below code in C program.

int a = !! b ;

variable b is also an integer. Initially I thought it is 'not' operator with a typo :)

Can someone help in explaining this?

darthvading
  • 909
  • 2
  • 11
  • 25

1 Answers1

4

This is operator !, which is used twice in row. If b is non-zero, a gets value 1, and if b is zero, a gets value 0.

VLL
  • 9,634
  • 1
  • 29
  • 54