\n\r

Posted by Ithildin on Sat 27 Mar 2004 04:39 PM — 4 posts, 18,595 views.

USA #0
i know this adds a return, but what does the n and r stand for. also. is there a way to take away a return...like a negative return. instead of adding a new line, could you take a way a line? just tryin to brush up on this stuff you guys call coding ;)

Thanks,
Ithildin
USA #1
ok, found out that \n = new line
and \r = Carriage return.

for all you guys out there who wants to know.

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. See Trigraphs 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 




i'm wondering if \b would work..but i'll check it out later. any other comments are welcome.

Amended on Sat 27 Mar 2004 05:07 PM by Ithildin
Hungary #2
Hmmm, I don't think it will work...
I made a little program in C, its code:
#include <stdio.h>
#include <conio.h>
main()
{
	int i;
	printf("Line 1.\n\rLine 2.\n\rLine 3.\n\rPress ENTER to continue!");
	getch();
	for(i=1;i<45;i++)
		printf ("\b");
	printf("Line rewritten.");
}


So it have to do it:
Line 1.
Line 2.
Line 3.
Press ENTER to continue!

End if we'll press any key, it have to write:
Line rewritten.
Line 2.
Line 3.


But it wrote only:
Line 1.
Line 2.
Line 3.
Line rewritten.continue!


So, the \b is usable to get back in a line, but isn't to get back whole lines.
But try it, maybe only my compiler is bad. (I've used Digital Mars)
Australia Forum Administrator #3
Backspace would generally be used when processing typing. It is a bit unusual for a server to send stuff to a client and then try to "take it back" with backspaces.

The client might support it, many wouldn't.