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".
2
  • 32 is not a string, so that won't work. You're going to have to call a macro to do the magic. Commented Sep 2, 2013 at 13:34
  • Check the double stringify trick here: Stringify macros Commented Sep 2, 2013 at 20:09

2 Answers 2

3
#define STR_NOEXPAND(tokens) # tokens
#define STR(tokens) STR_NOEXPAND(tokens)
puts("Blah" STR(TAG_LEN));
Sign up to request clarification or add additional context in comments.

1 Comment

Caution : underscore-prefixed identifiers are reserved for the implementation.
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);

1 Comment

Literal strings concatenation required here but not dynamic arrays copying

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.