#define paster( n ) printf_s( "token" #n " = %d", token##n )
int token9 = 9;

If a macro is called with a numeric argument like

 
paster( 9 );

the macro yields

 
printf_s( "token" "9" " = %d", token9 );

which becomes

 
printf_s( "token9 = %d", token9 );
 
// preprocessor_token_pasting.cpp
#include <stdio.h>
#define paster( n ) printf_s( "token" #n " = %d", token##n )
int token9 = 9;

int main()
{
   paster(9);
}
token9 = 9

相关文章:

  • 2022-12-23
  • 2021-09-06
  • 2021-12-01
  • 2022-12-23
  • 2021-05-17
  • 2022-12-23
猜你喜欢
  • 2021-12-15
  • 2022-12-23
  • 2021-09-16
  • 2022-12-23
  • 2022-02-15
  • 2022-01-02
  • 2022-12-23
相关资源
相似解决方案