Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Using ! in a function call in C

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.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>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 type int.
The expression !E is equivalent to (0==E).
C23dr § 6.5.3.3 5

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading