\r\n and \n\r aren't the same

I thought \r\n and \n\r would do the same in Windows but I am wrong.
Here is what I misunderstood:

\r\n:
First: \r: Carriage Return
Second: \n: New Line

\n\r:
First: \n: New Line
Second: \r: Carriage Return

So, the results should be the same. However, I tested and they aren't.

Could you explain why?
Because that is how it is.

Duoas wrote:
If you just throw a whole bunch of ingredients together into a baking dish and put it in the oven, you won't get a cake out. You'll get a bunch of burnt ingredients.

Why didn't it work? Because you did it wrong.

Bake according to instructions.




Everything the computer does, and the way it works, follows rules. And the rules change depending on what you are doing. Follow the rules in effect and things will work right.
It is a bit confusing.
\r will move cursor to the beginning of a line.
\n will make a new line.
So, in my thinking \r\n and \n\r are the same.
For example:
Where: ++ present cursor position

--------------------------------------------++----------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------

Now with \r\n:
First: \r

++------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------

Then: \n (and we get \r\n)

----------------------------------------------------------------------------------------------------------------
++------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------

Now with \n\r:

First: \n

---------------------------------------------------------------------------------------------------------------
---------------------------------------------++---------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------

Then: \r (and we get \n\r)

----------------------------------------------------------------------------------------------------------------
++------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------

As you can see, the results are the same.
What is wrong here?
Last edited on
Topic archived. No new replies allowed.