宏能实现循环功能不?
时间:2010-07-19
来源:互联网
例如,
#define foo(count) /* something here */
foo(1)可以得到 x
foo(2)可以得到 x x
foo(3)可以得到 x x x
...
#define foo(count) /* something here */
foo(1)可以得到 x
foo(2)可以得到 x x
foo(3)可以得到 x x x
...
作者: koolcoy 发布时间: 2010-07-19
是这个意思不?
#define foo(count) for(int i=0; i<count; i++) printf("x ");
#define foo(count) for(int i=0; i<count; i++) printf("x ");
作者: rain_fish 发布时间: 2010-07-19
LZ大概想要返回一个字符串
作者: hellioncu 发布时间: 2010-07-19
本帖最后由 群雄逐鹿中原 于 2010-07-19 12:11 编辑
嫌100个循环不够,先用script代码生成1000个好了
复制代码
嫌100个循环不够,先用script代码生成1000个好了
- #define FOR_1(x) x
- #define FOR_2(x) FOR_1(x) x
- #define FOR_3(x) FOR_2(x) x
- #define FOR_4(x) FOR_3(x) x
- #define FOR_5(x) FOR_4(x) x
- #define FOR_6(x) FOR_5(x) x
- ....
- #define FOR_100(x) FOR_99(x) x
-
- #define FOR_N(n,x) FOR_##n(x)
-
-
- int main()
- {
- FOR_N(3,99)
- return 0;
- }
-
-
- $ gcc -E t33.c
- # 1 "t33.c"
- # 1 "<built-in>"
- # 1 "<command line>"
- # 1 "t33.c"
- # 11 "t33.c"
- int main()
- {
- 99 99 99
- return 0;
- }
作者: 群雄逐鹿中原 发布时间: 2010-07-19
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28