I saw in the book that TRUE
/FALSE
was defined like this, but I don't know the reason.
#define TRUE '/'/'/'
#define FALSE '-'-'-'
What does this mean? Why can you write that one-zero?
c c++ boolean obfuscation macro
'/'/'/'
divides the characters '/'
from each other.
Would it be easier to understand?
Since a/a = 1
, you can write true
'-'-'-'
subtracts the letter -'
from each other.
In other words,
That's it.
Since a-a = 0
, you can write false
.
In fact, apart from what you can use, It's not a very good code.
It's not as readable as 0/1 Because the expression is not enclosed in parentheses.
If you run the following code because it is not enclosed in parentheses
#include <stdio.h>
#define TRUE '/'/'/'
#define FALSE '-'-'-'
int main() {
printf ("%d\n", 2 * FALSE);
return 0;
}
Output -
(45 on my computer)
#define TRUE ('/'/'/')
Please put parentheses together.
549 PHP ssh2_scp_send fails to send files as intended
717 When building Fast API+Uvicorn environment with PyInstaller, console=False results in an error
548 rails db:create error: Could not find mysql2-0.5.4 in any of the sources
539 Uncaught (inpromise) Error on Electron: An object could not be cloned
© 2024 OneMinuteCode. All rights reserved.