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

  • Home
  • SEARCH
  • 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 8988793
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T22:05:35+00:00 2026-06-15T22:05:35+00:00

Yesterday I post about a big contract for a new account program that must

  • 0

Yesterday I post about a big contract for a new account program that must be in C++. My question closed but I think
because it had to many errors. With much work and consuling from local C++ expert I’ve fixed the original codes we had:

#include <accounting.h>
#include <stdio.h>

char *main()
{
    accounting bank = 100debits;
    bank = bank + 200debits;
    return printf("bal: %accounting\n", bank);
}

And new version with some classes we defined works well but the only problem is C++ can’t write a new line to file.
The codes below work as is but I get no output to file if I put back the comment line.

#include <stdlib.h> 
#include <stdio.h>
#include <cstring>
#define accounting float
#define print_accounting(x)  x "%0.2f"
#define debits * 1.0F
#define credits * -1.0F

int main()
{
    accounting bank = 100 debits;
    bank = bank + 200 debits;
    char my_bal[((unsigned short)-1)];
    sprintf(my_bal, print_accounting("bal:"), bank);
    char write_file[((unsigned short)-1)];
    write_file[NULL] = 0;
    strcat(write_file, "@echo ");
    strcat(write_file, my_bal);
//  strcat(write_file, "\n");  -- Wont work --
    strcat(write_file, " > c:\\SAP_replace\\bal.txt");
    system(write_file);
    return 0;
}
  • 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-15T22:05:36+00:00Added an answer on June 15, 2026 at 10:05 pm

    echo will automatically write a newline to the end of the file.

    If you want two newlines, just add another line similar to:

    system ("echo. >>c:\SAP_replace\\bal.txt");
    

    after the current system() call.

    Or you could throw away the entire archaic idea of spawning another process to do output, and instead use iostreams to do the job. That’s the way you should be doing it in C++, something like:

    #include <iostream>
    #include <fstream>
    int main (void) {
        float fval = 0.123f;
        std::ofstream os ("bal.txt");
        os << "bal: " << fval << '\n';
        os.close();
        return 0;
    }
    

    which outputs:

    bal: 0.123
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I made a post about this yesterday, but it is a fairly different question.
I posted this question yesterday but received some valuable feedback that my post left
I asked a question yesterday about password safety... I am new at security... I
I've posted a question yesterday but I just realized that the answer doesn't seem
Yesterday , I asked a question about socket post file data to php page.
I had a response on a question yesterday about sending POST data to the
Yesterday I've posted question about SQLite performance issues ( Terrible performance in Zend Db
yesterday I took a database exam and the question about normalization was strange. We
As per a question that I asked yesterday I was trying to find a
I asked a fairly poor question yesterday, but I still have the same general

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.