0

How is the result is "Sololearn" here? Could someone explain please?

#define SOLO 42 int main() { #if !SOLO printf("Try Again"); #else printf("SoloLearn"); #endif return 0; }

21st Aug 2021, 5:43 PM
mesarthim
mesarthim - avatar
2 Respostas
+ 4
When "SOLO" is replaced by 42, the condition !SOLO is evaluated to false since all non-zero values are considered to be true, thus the negation is false. As a result, only the code inbetween the #else and #endif directives is compiled, making the output "SoloLearn".
21st Aug 2021, 5:52 PM
Shadow
Shadow - avatar
0
Thanks for effort Shadow
21st Aug 2021, 5:54 PM
mesarthim
mesarthim - avatar