質問

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".
役に立ちましたか?

解決

#define STR_NOEXPAND(tokens) # tokens
#define STR(tokens) STR_NOEXPAND(tokens)
puts("Blah" STR(TAG_LEN));

他のヒント

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);
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top