首页 > 编程语言 > 详细

输出C语言中 变量的类型

时间:2014-11-22 11:59:59      阅读:331      评论:0      收藏:0      [点我收藏+]

使用gcc的警告信息间接知道变量的类型

 

#include <stdio.h>
#include <stdlib.h>
#include <stddef.h>
#include <string.h>

int
main()
{
        int a[2][10];

        printf("%d\n", a[0]);
        printf("%d\n", a);
        printf("%d\n", a + 1);

        exit(0);
}
[root@localhost transform]# gcc -o test -Wall -g test.c
test.c: In function ‘main’:
test.c:14: warning: format ‘%d’ expects type ‘int’, but argument 2 has type ‘int *’
test.c:15: warning: format ‘%d’ expects type ‘int’, but argument 2 has type ‘int (*)[10]’
test.c:16: warning: format ‘%d’ expects type ‘int’, but argument 2 has type ‘int (*)[10]’

gcc 的选项中加入 -Wall 即可

 

输出C语言中 变量的类型

原文:http://www.cnblogs.com/lxgeek/p/4114894.html

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