Page 1 of 1

Carriage Return

Posted: Tue Feb 16, 2010 5:16 am
by spacebiscuit
What is the difference between:

'\r' and '\n'

I know that they are used as a carriage returm, is it possible to use them seperately or are they always used in conjunction with each other?

Thanks,

Rob.

Re: Carriage Return

Posted: Tue Feb 16, 2010 7:15 am
by requinix
They're simply two different characters. \r is a carriage return, \n is a line feed.

Mostly for line endings: Unix uses \n, Windows uses \r\n, and Mac uses \r.

Re: Carriage Return

Posted: Tue Feb 16, 2010 8:26 am
by spacebiscuit
Thanks for clearing that one up!

Rob.

Re: Carriage Return

Posted: Tue Feb 16, 2010 8:41 am
by AbraCadaver
tasairis wrote:They're simply two different characters. \r is a carriage return, \n is a line feed.

Mostly for line endings: Unix uses \n, Windows uses \r\n, and Mac uses \r.
Does the newer OS X still use \r or the unixy \n or does it depend upon the program? I would assume that whatever the GUI apps use, vi or other such unixy program would still use \n.