宏定义/#argument/##

来源:互联网 发布:淘宝买口红靠谱吗 编辑:程序博客网 时间:2024/05/16 07:25

/*

** 程序1

*/

#include <stdio.h>

 

#define PRINT(FORMAT, VALUE) /

                    printf("The value of " #VALUE " is " FORMAT "/n", VALUE); /

                    printf("The value is: " FORMAT "/n", VALUE)

                    //#argument结构被预处理翻译为"argument"printf临近字符串自动连接

void main()

{

       int x = 0;

 

       PRINT("%d", x+3);

}

 

 

/*

** 程序2

*/

#include <stdio.h>

 

#define ADD_TO_SUM(sum_number, value) /

                           sum ## sum_number += value

                           //##把它两边的符号链接成一个符号

void main()

{

       int sum5 = 9;

      

       printf("%d/n", ADD_TO_SUM(5, 25));

}

原创粉丝点击