Answer the question
In order to leave comments, you need to log in
How to form a string using C macros?
Good day!
In someone else's header file there is:
You need to get:
#define stamp "stamp n.10" // где 10 берётся выше, в строке пробел обязателен
#define mkstr(s) # s
#define concat(a,b) a ## b
#define stamp mkstr(concat(stamp n., number))
Answer the question
In order to leave comments, you need to log in
I know that here it is necessary to use "magic" with an intermediate macro, but I can't figure out how to implement it.
#define number 10
#define mkstr2(s) #s
#define mkstr(s) mkstr2(s)
#define stamp "stamp n." mkstr(number)
#include <stdio.h>
int main()
{
printf("%s", stamp); // stamp n.10
return 0;
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question