首页 > 编程语言 > 详细

【C语言】【面试题】【笔试题】对于宏的使用,if endif #define _DEBUG_ ifdef _DEBUG_

时间:2015-11-01 19:46:46      阅读:397      评论:0      收藏:0      [点我收藏+]
#if 0             //如果条件为真执行下面代码,如果为假不执行,这里0为假
#include <stdio.h>

int main()
{
	return 0;
}
#endif //结束if宏定义

#define _DEBUG_ 0 //定义_DEBUG_

#include <stdio.h>

int main()
{

	printf("this is a test\n");
	int i = 0;
	int arr[100];
	for (i = 0; i < 100; i++)
	{
		arr[i] = 100 - i;
//#if 0   //跟endif配套使用
//#ifdef _DEBUG_    //跟下面两种表示方法一样
//#if defined(_DEBUG_)//同上
#if _DEBUG_    //只要_DEBUG_被定义后面的程序就会被执行,前面就定义了_DEBUG_,所以下面程序将会执行
		if (i == 10)
		{
			printf("%d\n", arr[i]);
		}
#endif
//#endif
	}
	system("pause");
	return 0;
}


【C语言】【面试题】【笔试题】对于宏的使用,if endif #define _DEBUG_ ifdef _DEBUG_

原文:http://10740329.blog.51cto.com/10730329/1708379

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!