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
  • 859
  • 2
  • 10
  • 23

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
  • 8,590
  • 1
  • 26
  • 50