美文网首页C,让你又爱又恨
1.宏定义下#,##的用法

1.宏定义下#,##的用法

作者: 傻子online | 来源:发表于2020-09-05 09:11 被阅读0次

1.#的宏定义

#include<stdio.h>

#include <stdlib.h>        调用system的头文件

#define ABC(x) #x        定义ABC(x)为一个字符串“x”

int main()

{

    printf(ABC(ab\n));    \n为换行符

    system("pause");

    return 0;

}

输出结果为:ab

1.##的宏定义

#include<stdio.h>

#include <stdlib.h>

#define ABC(x)  #x

#define day(x)  myday##x 

##相当于定义一个后缀名,千万要注意define宏定义    相当于只是一个代号,里面存的值还是由你定义

int main()

{

    int myday1=10;

    int myday2=20;

    printf("the day is %d\n",day(1));

    system("pause");

    return 0;

}

输出结果为the day is 10;

链接:http://note.youdao.com/noteshare?id=87a76723fd79780da5edc5fec7ae3a72&sub=87E6913D75324C05B23916899F0B1482

相关文章

网友评论

    本文标题:1.宏定义下#,##的用法

    本文链接:https://www.haomeiwen.com/subject/mroosktx.html