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"
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.