dimanche 29 mars 2015

How to Understand this #define in C [duplicate]




This question already has an answer here:




I'm currently reading "The C puzzle book" and I found a #define that I would like to understand how it works.



#define PRINT(int) printf(#int " = %d\n", int)


I've never seen something like #int before so I wrote a small program to try the above



#include <stdio.h>
#define PRINT(int) printf(#int " = %d\n", int)
int main()
{
PRINT(10);
}

Result: 10 = 10


How does the preprocessor interpret #int in this case and where can I read more about this?


Thanks.




Aucun commentaire:

Enregistrer un commentaire