首页 > 其他 > 详细

解决warning: format ‘%x’ expects type ‘unsigned int’, but argument 2 has type ‘int *’

时间:2014-11-06 02:09:14      阅读:1108      评论:0      收藏:0      [点我收藏+]

[root@CC c]# gcc MemTest.c -o MemTest1 -Wall
MemTest.c: In function ‘main’:
MemTest.c:24: warning: format ‘%x’ expects type ‘unsigned int’, but argument 2 has type ‘int *’
MemTest.c:39: warning: format ‘%x’ expects type ‘unsigned int’, but argument 2 has type ‘int *’

MemTest.c:24: warning: cast from pointer to integer of different size
MemTest.c:39: warning: cast from pointer to integer of different size



代码中增加下面对应颜色的部分
int i, *intptr=NULL;
intptr = (int *)malloc(sizeof(int)*16);
printf("intptr address: 0x%x\n", (unsigned int)(long)intptr);

解决warning: format ‘%x’ expects type ‘unsigned int’, but argument 2 has type ‘int *’

原文:http://richmond.blog.51cto.com/1345557/1572733

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