c/c++ 变量名前面加井号#
2016-07-13 13:23
399 查看
#把宏参数变成一个字符串。
eg:
From:purple尘
eg:
#include<stdio.h> #define ABC(str1, str2) \ char outstr1[100] = #str1; \ char outstr2[100] = #str2; int main() { ABC(thisisstr1, thisisstr2); printf("outstr1=%s, outstr2=%s", outstr1, outstr2); return 0; }
输出: outstr1=thisisstr1, outstr2=thisisstr2
From:purple尘
相关文章推荐
- 1042. 字符统计(20)
- 1012. 数字分类 (20)
- C语言面试之CPU控制
- 1011. A+B和C (15)
- 1009. 说反话 (20)
- 《C++ Primer Plus》第13章 类继承 笔记
- 1006. 换个格式输出整数 (15)
- 1001. 害死人不偿命的(3n+1)猜想 (15)
- C++ STL标准模板库(stack)
- 292. Nim Game
- 线程对象
- effective c++读书笔记 条款2
- C++中struct和class的区别
- memcpy,strcpy,strncpy的用法
- 简单的词法分析和语法分析(C++实现,CodeBlocks+GCC编译)
- Leetcode 8. String to Integer (atoi) (Easy) (cpp)
- 不调用C/C++的字符串库函数,请编写函数strcpy
- 338. Counting Bits
- NOIP2015提高组 信息传递(图论)
- 在亚马逊开店的注意事项—跨海汇