Escape Sequences

news/2025/2/23 10:24:07
http://msdn.microsoft.com/en-us/library/ms860944.aspx

Escape Sequences

Character combinations consisting of a backslash (\) followed by a letter or by a combination of digits are called “escape sequences.” To represent a newline character, single quotation mark, or certain other characters in a character constant, you must use escape sequences. An escape sequence is regarded as a single character and is therefore valid as a character constant.

Escape sequences are typically used to specify actions such as carriage returns and tab movements on terminals and printers. They are also used to provide literal representations of nonprinting characters and characters that usually have special meanings, such as the double quotation mark ("). Table 1.4 lists the ANSI escape sequences and what they represent.

Note that the question mark preceded by a backslash (\?) specifies a literal question mark in cases where the character sequence would be misinterpreted as a trigraph. SeeTrigraphs for more information.

Table 1.4   Escape Sequences

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

\xhhh

ASCII character in hexadecimal notation


Microsoft Specific —>

If a backslash precedes a character that does not appear in Table 1.4, the compiler handles the undefined character as the character itself. For example,\x is treated as an x.

END Microsoft Specific

Escape sequences allow you to send nongraphic control characters to a display device. For example, the ESC character (\033) is often used as the first character of a control command for a terminal or printer. Some escape sequences are device-specific. For instance, the vertical-tab and formfeed escape sequences (\v and\f) do not affect screen output, but they do perform appropriate printer operations.

You can also use the backslash (\) as a continuation character. When a newline character (equivalent to pressing the RETURN key) immediately follows the backslash, the compiler ignores the backslash and the newline character and treats the next line as part of the previous line. This is useful primarily for preprocessor definitions longer than a single line. For example:

#define assert(exp) \
( (exp) ? (void) 0:_assert( #exp, __FILE__, __LINE__ ) )

http://www.niftyadmin.cn/n/1734643.html

相关文章

define 的用法

http://baike.baidu.com/view/1441209.htm #define中的#与##   在#define中&#xff0c;标准只定义了#和##两种操作。#用来把参数转换成字符串&#xff0c;##则用来连接两个前后两个参数&#xff0c;把它们变成一个字符串。 #include <stdio.h> #define paster(n) p…

python函数的位置参数(Positional)和关键字参数(keyword)

python函数具有各种灵活的参数, 功能着实强大. 不过因为过于灵活, 故比较难于理清, 所以给初学者带来了不小的困扰. 以下是我搜集的资料, 力图将这个问题明朗化. 1. parameter 和 argument 以前一直认为这两个单词的含义是相同的, 今天才发现其实不然. parameter 为函…

python 条件判别中出现 “invalid syntax“ 错误的解释

今天用python写一个简单的脚本, 运行时却总是报错, 当时简直要手足无措了, 好在解决了. 现在把它记下来, 希望能够对其他人有所帮助. 问题代码如下: fIn open("d:/DeskTop/4通道数据.txt", "r", encoding"utf8") while s fIn.readline():pa…

由 WGestures 导致的 Win10系统莫名关机问题

之前有一段时间, 自己所用的win10系统运行一段时间后, 总是莫名奇妙的突然关机. 时间不固定, 有时次数也很频繁. 当时上网找了很多的解决办法, 但总也不奏效. 最后通过把shutdown.exe替换掉, 才勉强能用, 但仍然过一段时间就发现shutdown.exe被调用了.   本想追踪一下是什么程…

Visual Studio Code(VSC)的列模式快捷键切换

在windows平台下, VSC的默认列模式快捷键如下: alt鼠标     //点选或拖动, 变行位置多列选择 altshift鼠标   //拖动, 同行位置多列选择 但在其他编辑器中, 我们一般都是用 alt鼠标拖动 的, 这个用起来最顺手, 在VSC中突然改变了习惯, 总觉得不那么方便. 一直想通过改快…

关于中英文等宽字体的设置

这两天折腾的东西如下: 在win10下面使用powershell时, 发现无法进行utf-8输出, 最后发现可以通过如下方法搞定: 控制面板->区域->管理->更改系统区域设置…-> Beta版:使用Unicode UTF-8提供全球语言支持(U) 该方法目前可完美解决, 不需要其他的额外配置. 如果有些较…

文本编辑: 表格内容自动tab对齐

经常用文本格式来看文章的人都会遇到这样一件事情, 就是把外部的表格复制过来后, 一般都不能很好的对齐. 一直以来, 我都是手动一行行一列列地把它们理整齐, 虽然费力, 但经手一遍后, 也算颇有收获. 但有时任务量实在是太大了, 总是在重复性的劳动, 让人不免大为光火. 今天终于…

给txt格式的文档增加目录

在电脑上看文档, 我觉得还是txt格式的最方便, 不仅打开速度快, 而且当你发现不合适的地方时也可以随手修改, 还可以方便地对其进行备注. 但是txt格式的文档有一个最大的缺点, 那就是没有目录, 这样当我们看稍长一点的文档就很不方便.   在实际使用中, 我总结出了一种让txt生成…