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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值