Search code examples
windowslinuxmacosunixline-endings

How does line ending effect in coding?


Why do line ending differ from platform to platform? Even why is there term like line ending in programming?

I prefer saving my codes in Unix/Linux format, even if I'm on Windows. Am I missing anything by not saving it in Windows or MacOS format? How does line ending effect in coding.


Solution

  • Basically everyone wanted to be different when creating OS's - Un*x's started with LF, then VMS and DOS wanted CR/LF (like a typewriter) and of course MAC wanted to be different so they went for CR only.

    They just wanted to make it harder to transfer between OS's so that you 'bought' into one

    Added because of comment

    Up to the programmer - if you need to support different line endings then you must code for them. eg you could create a #define for the line ending and then have this change depending on compile options