Can someone help me with an explanation of how to understand the ! operator in function calls in C?
For example, bool misspelled = !check(word);
The check() function in this case is supposed to return a bool. So does the ! here mean that misspelled will be assigned the opposite value of whatever check() returns?
I haven’t tried using it yet. I’m still a beginner, learning the meaning and usage of C.
>Solution :
The result of the logical negation operator
!is:
0 if the value of its operand compares unequal to 0,
1 if the value of its operand compares equal to 0.
The result has typeint.
The expression!Eis equivalent to(0==E).
C23dr § 6.5.3.3 5