For the following code I am getting output as- Geeks.
#include <stdio.h>
#define ISEQUAL(X, Y) X == Y
int main()
{
#if ISEQUAL(X, 0)
printf("Geeks");
#else
printf("Quiz");
#endif
return 0;
}
Explain the reason for such output.
The conditional macro #if ISEQUAL(X, 0)
is expanded to #if X == 0
. After the pre-processing is over, all the undefined macros are initialized with default value 0
. Since macro X
has not been defined, it is initialized with 0
. So, "Geeks" is printed.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.