3

Let the first row be:

#define TAG_LEN 32

Now, I need to concatenate it with a literal string constant; something like that:

puts("Blah" [insert your answer] TAG_LEN); // I need "Blah32".
Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
coderodde
  • 1,269
  • 4
  • 17
  • 34
  • `32` is not a string, so that won't work. You're going to have to *call* a macro to do the magic. – unwind Sep 02 '13 at 13:34
  • Check the double stringify trick here: [Stringify macros](http://stackoverflow.com/questions/2751870/how-exactly-does-the-double-stringize-trick-work) – pablo1977 Sep 02 '13 at 20:09

2 Answers2

3
#define STR_NOEXPAND(tokens) # tokens
#define STR(tokens) STR_NOEXPAND(tokens)
puts("Blah" STR(TAG_LEN));
not-a-user
  • 4,088
  • 3
  • 21
  • 37
0

you can do:

printf("Blah%d", TAG_LEN);

or if you have a string

char *yourString;// initiate it with your value

printf("Blah%s%d",yourString, TAG_LEN);
No Idea For Name
  • 11,411
  • 10
  • 42
  • 70