I came across this following code:
#include<stdio.h>
#define d(x) x(#x[3])
int main(){
d(putchar);
}
Which prints c as the output. I wonder what does the macro #define d(x) x(#x[3]) does? In C language is there an operator like #? I can see this inside the macro body i.e here x(#x[3]). According to my normal eye it looks something different I see in C language but actually What does this does?
Edit : Whats the real use of # in real world?
I’m a novice in C and it will be good if the explanation is in simple terms. Thanks in advance.
The character ‘#’ is a stringizer — it turns a symbol into a string. The code becomes
putchar(“putchar”[3]);