#define指令的作用
来源:互联网 发布:阿里巴巴斑马网络 编辑:程序博客网 时间:2024/05/17 01:42
1
2
3
4
5
6
7
8
9
10
11
12
13
给定下列例子,加深了解#define指令。
#define是预处理命令,它的作用域是从定义开始直至文件结尾。那么下列程序的输出是什么呢?
答案是10,10。
相当于预处理阶段将a全部都替换为10.
#define a 10
void
foo();
main(){
printf
(
"%d"
,a);
foo();
printf
(
"%d"
,a);
}
void
foo(){
#undef a
#define a 50
}
那如果程序改成下列:
#define a 10
void
foo(){
#undef a
#define a 50
}
main(){
printf
(
"%d"
,a);
foo();
printf
(
"%d"
,a);
}
那么程序输出将是50,50。
欢迎大家批评指正。
2 0
- #define指令的作用
- #define指令的作用
- #define WIN32_LEAN_AND_MEAN 的作用
- #define WIN32_LEAN_AND_MEAN 的作用
- define的作用域
- #define的作用域
- #define的作用域
- define中#的作用
- #define WIN32_LEAN_AND_MEAN 的作用
- #define WIN32_LEAN_AND_MEAN 的作用
- #define __STDC_CONSTANT_MACROS的作用
- #define中#和##的作用
- #define 中 # 和 ## 的作用
- ifndef define endif的作用
- ifndef/define/endif的作用
- #ifndef #define #endif的作用
- #ifndef #define #endif的作用
- #define中#和##的作用
- MiniUI支持Java Struts MVC
- JSTL自定义标签
- com.mysql.jdbc.MysqlDataTruncation: Data truncation: Data too long for column MenuGrpCode at row 1
- android ios和js接口互调
- 我的微信公众平台开通啦!
- #define指令的作用
- 补做实验二
- eclipse 配置
- YII2 unknown scenarios:default问题原因查找
- 安卓获取图片缩略图的两种方式
- android-----XUtils框架之HttpUtils源码分析
- AsynTask版本兼容问题
- BZOJ 1517 [POI2006]Met
- ViewRootImpl入门