How to use preprocessor ## to concatenate the left and right sides in C

2 Answers

0 votes
#include <stdio.h>

#define CONCATENATE(a, b) a##b

int main()
{
    printf("%d", CONCATENATE(12, 90));

    return 0;
}



/*
run:

1290

*/

 



answered Jul 26, 2024 by avibootz
0 votes
#include <stdio.h>

#define CONCATENATE(a, b) a##b

int main()
{
    printf("%f", CONCATENATE(3.14, 999));

    return 0;
}



/*
run:

3.149990

*/

 



answered Jul 26, 2024 by avibootz
...