Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7648707
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T10:47:05+00:00 2026-05-31T10:47:05+00:00

Before you declare this question as a duplicate of this or that , please

  • 0

Before you declare this question as a duplicate of this or that, please consider that I’ve submitted a problem to the online judge with \n and got WA, and then with std::endl and got AC. So, I need a very specific answer to the point of platform awareness: Is \n really platform aware, and does the runtime really write the correct line ending according to the platform as the answers to the other questions claim? If so, could you please tell me how this happened??

If the answer can be supported by a citation from the standard regarding the platform awareness issue, I’d be really thankful. I’ve read all the other questions’ answers (even the closed ones), so please don’t repeat the “flushes the buffer” thing.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T10:47:06+00:00Added an answer on May 31, 2026 at 10:47 am

    From C++11, §27.7.3.8 –

    namespace std
    {
        template <class charT, class traits>
            basic_ostream<charT,traits>& endl(basic_ostream<charT,traits>& os);
    }
    

    Effects:Calls os.put(os.widen(’\n’)), then os.flush().

    Returns:os.

    So, from the standard it’s clear that endl flushes the output stream buffer, while \n doesn’t. Generally you will want to use endl for printing a new line, but you should also keep in mind that every time you do that the output buffer will get flushed too.

    About the platform awareness

    From the standard it’s obvious that both does the exact same thing – printing a new line in the exact same way. So, if one is platform independent, then the other should also be the same. Since I know for sure endl is platform independent, same should be the case for \n.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know this question was asked before, but before marking it as a duplicate,
Sorry if this question has been asked before. On my search through SO I
I vaguely recall seeing this before in an answer to another question, but searching
Possible Duplicate: Can someone Explain this jQuery code? I have posted this before, but
This question HAS had to be asked before, so it kills me to ask
Yes, I know this question has been asked dozens of times before. However, when
My previous question about this subject was answered and I got some tests working
Although this question have been asked and answered before, including on this website, I
I'm sure this question has been asked before, but I can't seem to find
I'm not sure if this question has been asked before ( searched through SOF

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.