K& R2 2.3:/ n vs / r [英] K&R2 2.3 : /n vs /r

查看:48
本文介绍了K& R2 2.3:/ n vs / r的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

K& R的2.3节列举了完整的转义序列。


Q1)是否可以在不进入

的情况下提出以下问题实施/平台谈话?


Q2)换线和回车之间的区别是什么?


MPJ

解决方案

Merrill& Michele写道:

K& R的第2.3节列举了完整的转义序列。

Q1)是否可以在不进入的情况下提出以下问题
实施/平台谈话?

Q2)换线和回车的区别是什么?

MPJ




''\ r''只是一个回车符,而''\ n''是一个回车符号

换行符。请注意,回车就是这样,它将

光标移动到当前行的开头,并且不会移动到下一行的




在这里你必须要小心,因为UNIX文本文件与Windows文本文件格式不同,并且从一个o / s移动时需要转换
到另一个。


" Merrill&米歇尔" <是******** @ comcast.net>写在

新闻:ma ******************** @ comcast.com:

K& R的2.3节列举了完整的转义序列。

Q1)是否可以在不进入实施/平台谈话的情况下提出以下问题?


我想是这样的。

Q2)换行和运输之间的区别是什么?




首先,不像你在主题行中写的那样,它们是:\ n和\ r。新的

行移动光标行。向下一行,即到一个新行。一个马车

返回带来的光标回到左边缘。是否单独处理或者做同样的事情可能是特定于实现的。


-

- 马克 - >

-


Merrill& Michele写道:

K& R的第2.3节列举了完整的转义序列。

Q1)是否可以在不进入的情况下提出以下问题
实施/平台谈话?


可能没有。

Q2)新行和回车之间的区别是什么?




我认为回车(''\ r'')返回左边距没有

推进一条线;

和换行符(''\ n '')前进一行*并*返回左边距


#include< stdio.h>


int main(void ){

printf(1。非常长的线条\r ---- \ n);

printf(" 2.很长的线条\\ n \\ n \\ n \\ n \\ n \\ n \\ n \\ n \\ n \\ n ---- \ n");

printf(" 3.很长行\\\ ---- \ n");

返回0;

}

Linux输出(gcc 3.3.5)*和* Windows 2000(gcc 3.3.3 / DJGPP)

---- ERY LONG LINE

2.非常长的线路

----

3.非常长的线路/>
----

-

如果每个人都读到USENET将是一个更好的地方:
http://www.expita.com/nomime.html
http://www.netmeister.org/news/learn2quote2.html
http://www.catb.org/~esr/faqs/smart-questions.html


Section 2.3 of K&R enumerates the complete set of escape sequences.

Q1) Is it possible to ask the following question without getting into
implementation/platform talk?

Q2) What on earth is the difference between newline and carriage return?

MPJ

解决方案

Merrill & Michele wrote:

Section 2.3 of K&R enumerates the complete set of escape sequences.

Q1) Is it possible to ask the following question without getting into
implementation/platform talk?

Q2) What on earth is the difference between newline and carriage return?

MPJ



''\r'' is simply a carriage return whereas ''\n'' is a carriage return followed
by line feed. Note that a carriage return is simply that, it moves the
cursor to the beginning of the current line and does not move on to the
next line.

It is here you have to be careful as UNIX text files are of a different
format from Windows text files and need conversion when moving from one o/s
to the other.


"Merrill & Michele" <be********@comcast.net> wrote in
news:ma********************@comcast.com:

Section 2.3 of K&R enumerates the complete set of escape sequences.

Q1) Is it possible to ask the following question without getting into
implementation/platform talk?
I guess so.
Q2) What on earth is the difference between newline and carriage
return?



First, unlike you wrote it in the subject line, they are: \n and \r. A new
line moves the "cursor" down one line, that is, to a new line. A carriage
return brings the "cursor" back to the left margin. Whether they are
treated separately or do the same thing may be implementation specific.

--
- Mark ->
--


Merrill & Michele wrote:

Section 2.3 of K&R enumerates the complete set of escape sequences.

Q1) Is it possible to ask the following question without getting into
implementation/platform talk?
Probably not.
Q2) What on earth is the difference between newline and carriage return?



I think carriage return (''\r'') returns to the left margin without
advancing a line;
and newline (''\n'') advances a line *and* returns to the left margin

#include <stdio.h>

int main(void) {
printf("1. VERY LONG LINE\r----\n");
printf("2. VERY LONG LINE\n----\n");
printf("3. VERY LONG LINE\r\n----\n");
return 0;
}
Output on Linux (gcc 3.3.5) *and* Windows 2000 (gcc 3.3.3 / DJGPP)
----ERY LONG LINE
2. VERY LONG LINE
----
3. VERY LONG LINE
----
--
USENET would be a better place if everybody read:
http://www.expita.com/nomime.html
http://www.netmeister.org/news/learn2quote2.html
http://www.catb.org/~esr/faqs/smart-questions.html


这篇关于K&amp; R2 2.3:/ n vs / r的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆