转义序列 \f - 换页 - 它到底是什么?

发布于 2024-10-05 13:56:53 字数 479 浏览 4 评论 0 原文

\f 被认为是换页符。 \t 是制表符,\a 是蜂鸣声,\n 是换行符。换页符到底是什么 - \f?以下程序

#include <iostream>
int main()
{
   std::cout << "hello\fgoodbye" << std::endl;  
}

打印hello,然后打印女性符号(颠倒的圣手榴弹:),然后再见全部写在一行上。

\f is said to be the form feed. \t is a tab, \a is a beep, \n is a newline. What exactly is a form feed - \f? The following program

#include <iostream>
int main()
{
   std::cout << "hello\fgoodbye" << std::endl;  
}

prints hello then a female sign (an upside down holy hand grenade:) and then goodbye all on one line.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

心如狂蝶 2024-10-12 13:56:53

它跳到下一页的开头。 (主要适用于输出设备是打印机而不是 VDU 的终端。)

It skips to the start of the next page. (Applies mostly to terminals where the output device is a printer rather than a VDU.)

我不会写诗 2024-10-12 13:56:53

来自 wiki 页面

12(换页符,\f,^L),导致
打印机将纸张弹出到顶部
下一页,或视频终端
清除屏幕。

或更多详细信息此处

看来这个符号现在已经相当过时了,它的处理方式可能是(?)依赖于实现的。至少对我来说,您的代码给出以下输出(xcode gcc 4.2,gdb 控制台):

hello
    goodbye

From wiki page

12 (form feed, \f, ^L), to cause a
printer to eject paper to the top of
the next page, or a video terminal to
clear the screen.

or more details here.

It seems that this symbol is rather obsolete now and the way it is processed may be(?) implementation dependent. At least for me your code gives the following output (xcode gcc 4.2, gdb console):

hello
    goodbye
熟人话多 2024-10-12 13:56:53

如果您正在为1980年代风格的打印机编程,它将弹出纸张并启动新页面。您几乎可以肯定不需要它。

http://en.wikipedia.org/wiki/Form_feed

If you were programming for a 1980s-style printer, it would eject the paper and start a new page. You are virtually certain to never need it.

http://en.wikipedia.org/wiki/Form_feed

网名女生简单气质 2024-10-12 13:56:53

它来自fan-fold paper.

Trust me, you ain't gonna need it...

It comes from the era of Line Printers and green-striped fan-fold paper.

Trust me, you ain't gonna need it...

椒妓 2024-10-12 13:56:53

Although recently its use is undefined, a common and useful use for the form feed is to separate sections of code vertically, like so:
enter image description这里
(from http://ergoemacs.org/emacs/emacs_form_feed_section_paging.html)

Although recently its use is undefined, a common and useful use for the form feed is to separate sections of code vertically, like so:
enter image description here
(from http://ergoemacs.org/emacs/emacs_form_feed_section_paging.html)

满地尘埃落定 2024-10-12 13:56:53

的末端启动第二行

它要转到newline,然后添加空格以在第一行输出

Hello
     Goodbye

It's go to newline then add spaces to start second line at end of first line

Output

Hello
     Goodbye
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文