https://www.cnblogs.com/zhongzhe/p/3892682.html

 

#的功能是将其后面的宏参数进行字符串化操作(Stringfication),简单说就是在对它所引用的宏变量通过替换后在其左右各加上一个双引号

##被称为连接符(concatenator),用来将两个Token连接为一个Token,##符是把传递过来的参数当成字符串进行替代。

 1 #include<cstdio> 
 2 #include<climits>
 3 using namespace std; 
 4 #define STR(s) #s 
 5 #define CONS(a,b) int(a##e##b)
 6 int main() 
 7 { 
 8     printf(STR(vck)); // 输出字符串"vck" 
 9     printf("%d\n",  CONS(2,3)); // 2e3 输出:2000
10  return 0; 
11 }

 

相关文章:

  • 2022-12-23
  • 2021-10-10
  • 2022-01-22
  • 2021-07-05
  • 2022-02-14
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-11-22
  • 2022-03-07
  • 2022-01-19
  • 2021-06-13
  • 2021-05-18
  • 2022-12-23
相关资源
相似解决方案