Difference between c language if (a! = b) and if (a =! b)

Question: Question:

In the program like the title

if(a!=b)

of

if(a=!b)

I mistakenly wrote that, but I could compile it, but the program was stagnant there.
Does this statement make sense to be able to compile?

What does that mean?


postscript

for(i=0;i<n;i++){
    printf("check1");
    if(a=!b){
        実行コード
    }
}
printf("check2");

At that time, it was running and check2 was not output, and the program stagnated.

if(a!=b)

Then it worked fine.

Answer: Answer:

I think you are substituting the negative result of b into a.
If you think about it separately, it will be as follows.

if( a = (!b) )

Therefore, the comparison formula is if (a).
That is, whenever a is non-zero, it is treated as true.

Scroll to Top