码迷,mamicode.com
首页 > 其他好文 > 详细

字符常量的类型

时间:2014-10-09 17:01:28      阅读:169      评论:0      收藏:0      [点我收藏+]

标签:style   io   ar   sp   on   代码   size   as   har   

代码:

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

// C语言将字符常量视为int类型而非char类型

int main(void) {

	// sizeof(int) == 4
	// sizeof(char) == 1
	printf(sizeof(‘ABCD‘) == sizeof(int)? "True" : "False");

	printf("\n");

	char ch = ‘ABCD‘;
	printf("%c\n", ch);

	return EXIT_SUCCESS;
}

输出:

True
D


字符常量的类型

标签:style   io   ar   sp   on   代码   size   as   har   

原文地址:http://my.oschina.net/Xwoder/blog/325322

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!