How do you define a multiline macro in C?

Luis B picture Luis B · Oct 2, 2016 · Viewed 13.5k times · Source

How do you define a multiline macro in C?

Answer

shriroop_ picture shriroop_ · Oct 2, 2016

End every line of definition of macro with a \

#include <stdio.h>
#define MAX(a,b) {\
    printf("%d ", a); \
    printf("%d\n", b); \
}

int main()
{
    printf("Hello, World!\n");
    MAX(4, 5);
    return 0;
}