组合输出

A C Programming Language Puzzle Give a = 12 and b = 36 write a C function/macro that returns 3612 without using arithmetic, strings and predefined functions.

Below is one solution that uses String Token-Pasting Operator (##) of C macros. For example, the expression “a##b” prints concatenation of ‘a’ and ‘b’.

#include <stdio.h> 
#define merge(a, b) b##a 
int main(void) 
{ 
    printf("%d ", merge(12, 36)); //3612
    return 0; 
}
#include <stdio.h> 

int main() 
{ 
   printf("Current File :%s\n", __FILE__ ); 
   printf("Current Date :%s\n", __DATE__ ); 
   printf("Current Time :%s\n", __TIME__ ); 
   printf("Line Number :%d\n", __LINE__ ); 
   return 0; 
}
Current File :main.c
Current Date :Oct 17 2019
Current Time :16:11:19
Line Number :8

results matching ""

    No results matching ""