0
Can anyone explain this code please ?
#include<stdio.h> #define macro(r,a,b) b##a##r #define CHAOS macro(r,a,b) void CHAOS(int n){printf("%d",n);} int main(){ bar(4); bar(2); return 0; }
1 ответ
0
#define is a pre-processor directive first CHOAS is replaced by macro(r,a,b)
Again we have another #define it replaces macro(r,a,b) by b##a##r
## acts as token pasting operator
So b##a##r=bar
Hence void CHOAS(int n) is void bar(int n)
bar(4);//outputs 4
bar(2);//outputs 2
So,final output is 42
// From old post