In C we can use ## to concatenate two arguments of a parameterized macro like so:
arg1##arg2which returnsarg1arg2
I wrote this code hoping that it would concatenate and return me a string literal but I cannot get it to work:
#define catstr(x, y) x##y
puts("catting these strings\t" catstr(lmao, elephant));
returns the following error:
define_directives.c:31:39: error: expected ‘)’ before ‘lmaoelephant’
31 | puts("catting these strings\t" catstr(lmao, elephant));
| ^
| )
It seems the strings are concatenating but they need to be wrapped around quotes in order for puts to print it. But doing so, the macro no longer works. How do I get around this?