I know the following is a very trivial example, but how would I convert the following into a single function call that uses the preprocessor ##
'glue' operator?
void print_string(char *s)
{
printf("%s\n", s);
}
void print_num(int n)
{
printf("%d\n", n);
}
int main(void)
{
print_string("Hello");
print_num(5);
}
The only thing I can thing of (which doesn't really simplify anything) is:
#define PRINT(type) print_ ## type
PRINT(string)("Hello");
PRINT(num)(4);
Or, is there a better way to use that?