首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C语言 >

C语言匡助调试工具PRINT_INT(),便捷输出变量的地址

2012-12-21 
C语言辅助调试工具PRINT_INT(),便捷输出变量的地址#include stdio.h#define PRINT(i)do{\printf(%8s():

C语言辅助调试工具PRINT_INT(),便捷输出变量的地址

#include <stdio.h>#define PRINT(i)        do{                \    printf("%8s(): ", __FUNCTION__);       \    printf("&%-5s =0x%-6x, ", #i, &(i));   \    printf(" %-5s =0x%-6x"  , #i,  (i));   \}while(0)#define PRINT_INT(i)    do{                \    PRINT(i);                              \    printf("\n");                          \}while(0)#define PRINT_PTR(p)    do{                \    PRINT(p);                              \    printf(", *%-5s =0x%-6x\n", #p, *(p)); \}while(0)int main(int argc, char *argv[]){int x = 8;int *p = &x;PRINT_INT(x);PRINT_PTR(p);return 0;}


热点排行