C++字符串中转义符

Escape Sequence Represents

\a

Bell (alert)

\b

Backspace

\f

Formfeed

\n

New line

\r

Carriage return

\t

Horizontal tab

\v

Vertical tab

\'

Single quotation mark

\"

Double quotation mark

\\

Backslash

\?

Literal question mark

\ooo

ASCII character in octal notation

\xhh

ASCII character in hexadecimal notation

\xhhhh

Unicode character in hexadecimal notation if this escape sequence is used in a wide-character constant or a Unicode string literal. 

For example, WCHAR f = L'\x4e00' or WCHAR b[] = L"The Chinese character for one is \x4e00".

我们可以将任何字符表示为以下形式的通用转义字符: 

\ooo

这里 ooo 表示三个八进制数字,这三个数字表示字符的数字值。 

同样也可以用十六进制转义字符来定义字符: 

\xddd

//当ooo不符合八进制规则时,赋值随编译器不同

//'\010000' vs8为字符0(ASCII 0x30),应为取了\ooo 后的第一个0. bcb5为字符\b(ASCII 0x8),应为取了\010

//'\0999' vs8为字符9,取了\0后的9, bcb5为\0

你可能感兴趣的:(C++)