Possible Duplicate:
Macro for concatenating two strings in C
How to concatenate two strings with a macro?
I tried this but it does not give correct results:
#define CONCAT(string) "start"##string##"end"
You need to omit the ##
: adjacent string literals get concatenated automatically, so this macro is going to concatenate the strings the way you want:
#define CONCAT(string) "start"string"end"
For two strings:
#define CONCAT(a, b) (a"" b)
Here is a link to a demo on ideone.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With