C/Macro Preprocessor/Macro String
Join string
#include <stdio.h>
#define JOIN(a, b) a ## b
int main(void)
{
printf(JOIN("one ", "two"));
return 0;
}
Output string using Macro
#include <stdio.h>
#define output(i) printf("%d %d\n", i ## 1, i ## 2)
int main(void)
{
int count1, count2;
int i1, i2;
count1 = 10;
count2 = 20;
i1 = 99;
i2 = -10;
output(count);
output(i);
return 0;
}
Use macro to build string
#include <stdio.h>
#define MKSTRING(str) # str
int main(void)
{
int value;
value = 10;
printf("%s is %d", MKSTRING(value), value);
return 0;
}