摘要: 1. #的用法在C语言中,#可以用来宏的转换成字符量,它仅允许出现在带参数的宏的替换列表中程序如下: 1 #include <stdio.h> 2 #include <stdlib.h> 3 4 #define str1(s) #s 5 #define str2(s) "#s" 6 #define str3(s) '#s' 7 8 int 9 main(void)10 {11 char *hello = "HELLO";12 printf("%s = %s\n", str1(hello), he 阅读全文
posted @ 2012-10-21 21:42 leealways87 阅读(1198) 评论(0) 推荐(0) 编辑
摘要: 源网址:http://hi.baidu.com/xtuyvzkkkllstue/item/33ce141051de400f8fbde4e1感谢作者讲解,所以copy过来以流后用,如有不妥,请作者留言,我直接删除哈。#define do{} while(0) 什么意思#define do{} while(0) 为什么这么用什么情况下用宏定义do{}while(0);简单地说,就是能够实现复杂的定义,通用性强,任何情况下都适用。#define MACRO_NAME(para) do{macro content}while(0)的格式,总结了以下几个原因:1,空的宏定义避免warning:#defi 阅读全文
posted @ 2012-10-21 21:10 leealways87 阅读(404) 评论(0) 推荐(0) 编辑