C 编程(2)

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: [email protected] 字符类型 char, signed char, unsigned char char和int之间的相互转换(由实现决定) wchar_t类型,用于保存更大的字符集里的 字符,如Unicode,具体大小由实现决定, 该名字来源于C语言,是一个typedef 对于字符类型可以进行算术和逻辑运算 字符文字量(字符常量),如’a’,’0’,’\n’等 宽字符文字量形式为L’ab’,引号中的字符个 数由wchar_t决定,其类型是wchar_t Beijing University of Posts & Telecommunications Beijing [email protected] 字符类型示例 八进制 十六进制 十进制 ASCII 大字符集 \6 \x6 6 ACK \uXXXX 或者 \UXXXX \60 \x30 48 ‘0’ \u1e2b \137 \x05f 95 ‘_’ \uXXXX等价于\U0000XXXX char char char char v1 v2 v3 v4 = = = = “a\xah\129”; “a\xah\127”; “a\xad\127”; “a\xad\0127”; Beijing University of Posts & Telecommunications Beijing [email protected] 字符类型程序示例 char c = 255; // 0xff int i = c; 问题:i = ? 解决方法:使用unsigned char 或者 signed char标明 但是有些函数只接受普通char类型 void f(char c, signed char sc, unsigned char uc) { char* pc = &uc...
View Full Document

This note was uploaded on 02/10/2014 for the course ECE C++ taught by Professor Xiaoshengtang during the Fall '13 term at BUPT.

Ask a homework question - tutors are online