Reputation: 39
hi guys after i saw a code that Dennis Ritchie wrote it but i did not understand what this mean declaring more_space_toggle as (false) and after that (more_space_toggle = ! more_space_toggle) what does mean ? does it mean not operatore convert false to true or what ? thank you for asnwerring me.
#include <stdbool.h>
bool more_space_toggle = false;
more_space_toggle = !more_space_toggle;
Upvotes: 0
Views: 43
Reputation: 17143
more_space_toggle = !more_space_toggle;
will toggle what the boolean is storing as !
is the logical NOT operator. So if it currently stores false
, it will toggle to true
, and vice versa.
Upvotes: 1
Reputation: 54
! is logical NOT operator. Use this to reverse the logical state of its operand.
!true==false
or
!false==ture
Upvotes: 0