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 8858569
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T14:51:34+00:00 2026-06-14T14:51:34+00:00

This is just a quick question. But I am trying to output data to

  • 0

This is just a quick question. But I am trying to output data to a file, which works fine.
However I am also trying to implement a new line at the appropriate point so the data, prints on individual lines.

This is how my code currently looks:

main.cpp

Writer w("Output.txt");
    w.writeString("The number of words in the script are: ");
    w.writeInt(count);
    w.writeEol();
    w.writeString("The number of Officers in the script are: ");
    w.writeInt(ofCount);
    w.writeEol();
    w.writeString("The number of Courtiers in the script are: ");
    w.writeInt(cCount);
        w.close();

Writer.cpp

void Writer::writeEol()
{
    out << "\n" << endl;
}

My code has to be implemented this way as my whole system is built around it like this.

So my question is, how would I adjust my Writer::writeEol() to add a new line to my output file?

My output file currently comes out like this:

    The number of words in the script are: 32339The number of Officers in the script are: 2The number of Courtiers in the script are: 9

Any help is greatly appreciated. 🙂

  • 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-06-14T14:51:35+00:00Added an answer on June 14, 2026 at 2:51 pm

    Without a proper question I can just guess what you’re trying to learn, so feel free to update your “question” with an actual question:

    You’re essentially writing two line breaks into the file, depending on the encoding (i.e. Windows or Unix line breaks) you won’t see the difference:

    std::endl will automatically include the correct character to create a linebreak. There’s no need to write "\n" as well.

    Also you don’t have to pass std::endl to the stream unless you really want a line break at the specific position:

    std::cout << "The result is: ";
    std::cout << 50 << std::endl;
    

    Keep in mind that depending on your editor you might not see all line breaks, e.g. Windows Notepad won’t show a line break with only \n. It will instead appear as an invisible character. For actual line breaks that are accepted you’d beed \r\n. In comparison, the Open Source editor Notepad++ accepts and displays both kinds of line breaks.

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

Sidebar

Related Questions

just a quick question, was trying different ways to accomplish this, but ended with
Just getting started with Powershell and have a quick question. Trying to run this
This is just a quick question to understand correctly what happens when you create
This is just a quick question in C#. I have a scenario where I
Just a quick question about how you would go about implementing this. I want
hope this will be a quick easy question, I've just tried my app on
This is going to be a quick discussion, but I just wanted some feedback
OK, this is just a quick question and I might take some slack for
Just a quick question as I am trying to clarify my understanding of the
Just a quick question: I'm trying to plot a graph in R and I

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.