zoukankan      html  css  js  c++  java
  • C/C++预处理宏的总结

    1.定义顺序的无关性

      #define PI 3.14

      #define TWO_PI  2*PI

      这两句谁前谁后无所谓,因为预处理器不断迭代来实现宏替换,直到源文件中没有宏了才停止。

    2. 宏变量变成字符串

       #define str(x)  #x  

       例子:str (teststring)  ==> "teststring"

    3. 宏变量拼接

      #define print(n)  printf("%d ",x##n)

      例子:print(20) ==> printf("%d ",x20)

    4. 定义长字符串如何换行

      #define url  "http://www.baidu.com"

            "?hello=world&ni=hao"

      注意编译器会把两个相邻的字符串连接到一起,形成单个字符串。

  • 相关阅读:
    LeetCode.152
    python
    python
    python
    python
    python
    python
    python
    PyCharm2020.1激活码破解教程
    Python GUI编程(Tkinter)17、Menu鼠标右键菜单
  • 原文地址:https://www.cnblogs.com/guoxiaoqian/p/4338875.html
Copyright © 2011-2022 走看看