Bloods vs Crips meme, captioned "Which side are you on? backslash N or end-ell"
you are viewing a single comment's thread
view the rest of the comments
[–] 8 points 2 years ago (4 children)

No, there's no guarantee that in every context \n is translated portably.

  • source
  • parent
  • hideshow 4 child comments
  • [–] 16 points 2 years ago (3 children)

    The same is true of std::endl. std::endl is simply defined as << '\n' << std::flush; nothing more, nothing less. In all cases where endl gives you a "properly translated" newline, so does \n.

  • source
  • parent
  • hideshow 3 child comments
  • [–] 3 points 2 years ago

    Yeah it's an artificial dichotomy based on a popular misconception of what std::endl is and how \n is interpreted.

    Ultimately it does not ask about line endings, but about flushing, which is a completely orthogonal question.

  • source
  • parent