相关疑难解决方法(0)

这个C代码如何工作?

什么是a##b&#a

  #define f(a,b) a##b
  #define g(a)   #a
  #define h(a) g(a)

  main()
  {
          printf("%s\n",h(f(1,2)));  //how should I interpret this?? [line 1]
          printf("%s\n",g(f(1,2)));  //and this? [line 2]
  }
Run Code Online (Sandbox Code Playgroud)

这个程序如何运作?


输出是

12
f(1, 2)
Run Code Online (Sandbox Code Playgroud)

现在我明白了如何a##b#a工作.但为什么两种情况(第1行和第2行)的结果不同?

c stringification c-preprocessor

6
推荐指数
2
解决办法
3986
查看次数

标签 统计

c ×1

c-preprocessor ×1

stringification ×1