C语言笔记之一:字符常量integer character constant是int型
来源:互联网 发布:java正则表达式单引号 编辑:程序博客网 时间:2024/04/30 19:15
C99中的描述:
"An integer character constant is a sequence of one or more multibyte characters enclosed
in single-quotes, as in 'x'. A wide character constant is the same, except prefixed by the
letter L. With a few exceptions detailed later, the elements of the sequence are any
members of the source character set; they are mapped in an implementation-defined
manner to members of the execution character set."
"An integer character constant has type int. The value of an integer character constant
containing a single character that maps to a single-byte execution character is the
numerical value of the representation of the mapped character interpreted as an integer.
The value of an integer character constant containing more than one character (e.g.,
'ab'), or containing a character or escape sequence that does not map to a single-byte
execution character, is implementation-defined. If an integer character constant contains
a single character or escape sequence, its value is the one that results when an object with
type char whose value is that of the single character or escape sequence is converted to
type int."
标准中明确规定了字符常量的类型为int,所以sizeof('a')的值为4,sizeof('abcde')的值同样为4。
"The value of an integer character constant containing more than one character (e.g., 'ab'), or
containing a character or escape sequence that does not map to a single-byte execution character,
is implementation-defined."
多字符的字符常量的值是由编译器来决定的:
- C语言笔记之一:字符常量integer character constant是int型
- 注意!C语言的枚举enum是int型常量
- C 语言中的字符常数是 int 型
- 字符常量的类型是int
- C语言笔记系列之一——常量
- C语言入门教程之一变量和常量
- c 学习笔记之一 字符串常量
- c语言-常量变量笔记
- C语言中怎么把Int型转成字符型
- c语言字符常量当做整型
- C语言中字符常量和字符串常量的区别
- C语言中字符串常量和字符常量的区别
- C语言中的字符变量和字符常量
- constant常量
- C语言学习笔记 lesson7 常量
- C语言之常量(笔记三)
- c语言学习笔记-字符
- c语言中的字符类型指针赋值字符串常量
- 冒泡法和选择法排序
- Android电源管理相关应用技巧分享
- 从VC6到VS2005移植代码:warning C4996
- hibernate 原理说明
- ubuntu10.04安装mysql[有很多借鉴他人的地方]
- C语言笔记之一:字符常量integer character constant是int型
- Visual SourceSafe 多项目自动切换工具
- Web的系统测试方法
- asp笔记1----日期格式输出
- 无能者的借口:简答「公司规定」(转自联强EMBA广告邮件)
- PHP安装错误 configure: error: xml2-config not found. Please check your libxml2 installation.
- 矩阵乘法的实现-将2维数组作函数的参数
- 屏蔽字的实现(高效率)
- 想要成功,请记住!