#的功能是将其后面的宏参数进行字符串化操作(Stringfication),简单说就是在对它所引用的宏变量 通过替换后在其左右各加上一个双引号。
#define example(instr) printf("the input string is:\t%s\n",#instr)
#define example1(instr) #instr
当使用该宏定义时:
example(abc); 在编译时将会展开成:printf("the input string is:\t%s\n","abc");
string str=example1(abc); 将会展成:string str="abc";
而##被称为连接符(concatenator),用来将两个Token连接为一个Token。

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-10-07
  • 2021-08-21
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-03-06
  • 2021-05-26
  • 2022-12-23
  • 2021-10-28
  • 2021-12-19
  • 2021-06-11
相关资源
相似解决方案