Use exclamation marks! in C

I had a problem with exclamation marks and integers by reading the code in my help system.

Let's say I declared an integer variable called number - int number = 0;

Then I use the while function with an exclamation mark and number

while(!number)
{
    ...
}

I am confused by this because I do not know what it means !numberand that it would be possible to return the results? I'm not sure that this can be used, but, as I said, I saw this in my book.

So it would be great if someone could tell me what it means !numberand what it evaluates?

Thanks in advance.

+10
source share
6 answers

! . , ( ), . , 1.

int i = 13;
printf("i = %d, !i = %d\n", i, !i);
printf("!0 = %d\n", !(0));
+10

C 1, == 0 0, != 0. C 1 , 0 - false.

, number == 0, , .

+6

"". "true, == 0, false". Google " ", .

+4

. .

: -

: -! 0, 1

! 1 = 0

+1

(!) .

. / bool (boolean 0 false, Non zero True).

, false; , true. bool.

while(!number)
{
    ...
}

0, (! number), .. 0, " 0", "TRUE", while()

+1

- : c/++ = > #

   c/c++---> if(i)  ---->c# i!=0
   c/c++---> if(!i) ---->c# i==0

int = 1; c code

if(1)
{
  //your code
}

# code

if(1!=0)
{
  //your code
}
0

Source: https://habr.com/ru/post/1534978/


All Articles