How to contain escape sequences in macro definition #?
Asked 07 September, 2021
Viewed 2K times
c
  • 56
Votes

I am trying to use this macro definition in C:

#define STR(x) #x

Is it possible to contain some escape sequences inside x? e.g., I want to define a string like:

char* str = "'";

This declaration does not seem to work:

char* str1 = STR(');

If I must use this macro definition, is there some way to contain strings containing apostrophe "'"? Thanks!

c

1 Answer