Why should text files end with a newline?

后端 未结 18 1214
栀梦
栀梦 2020-11-21 22:56

I assume everyone here is familiar with the adage that all text files should end with a newline. I\'ve known of this \"rule\" for years but I\'ve always wondered — why?

18条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-11-21 23:27

    Basically there are many programs which will not process files correctly if they don't get the final EOL EOF.

    GCC warns you about this because it's expected as part of the C standard. (section 5.1.1.2 apparently)

    "No newline at end of file" compiler warning

提交回复
热议问题