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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T18:28:49+00:00 2026-05-21T18:28:49+00:00

Hello i am making a program that is supposed to copy a text file.

  • 0

Hello i am making a program that is supposed to copy a text file. The text file is just 3 lines of text at the moment. The textFileCopy function is supposed to read in a text file given by the filenamein array and then output a copy of the text file given by the filenameout array.

This is my main.cpp file. In this file the program requires the user to send an input filename and an output filename as arguments which i have just done using the command argument box in visual studio, the command argument box contains “input.txt output.txt” so this means that argv[1] contains the input file and argv[2] contains the output file which is to be created

#include <iostream>
#include <fstream>
#include <string>
using namespace std;

#include "FileUtilities.h"


int main(int argc, char **argv) {
    FileUtilities fileUtil;
    fileUtil.textFileCopy(false, false);
    if (argc !=3) {
        cerr << "Usage: " << argv[0] << " <input filename> <output filename>" << endl;
        int keypress; cin >> keypress;
        return -1;
    }

    fileUtil.textFileCopy(argv[1], argv[2]);

    int keypress; cin >> keypress;
}

And this is the FileUtilities.h file which declares the textFileCopy function

#include <iostream>
#include <fstream>
#include <string>
using namespace std;
#pragma once

class FileUtilities
{
public:
    bool textFileCopy(char filenamein[], char filenameout[]);
}; 

And here is the matching FileUtilities.cpp file including textFileCopy function

#include <iostream>
#include <fstream>
#include <string>

#include "FileUtilities.h"

bool FileUtilities::textFileCopy(char filenamein[], char filenameout[])
{
    ifstream fin(filenamein);
    if(fin.is_open())
    {
        ofstream fout(filenameout);

        char c;
        while(fin.good())
        {
            fin.get(c);
            fout << c;
        }

        fout.close();
        fin.close();

        return true;
    }
    return false;
}

I am having trouble creating the function defined in the .h file in the .cpp file and i get errors with this line FileUtilities::textFileCopy(char filenamein[], char filenameout[]) from the .cpp file. I know the actual code in the function works its just that first line

UPDATE

Ok so i have put bool before the function.

Now the program compiles and i get an error in a dialog box as follows

“Microsoft Visual C++ Debug Library

Debug Assertion Failed!

Program: …..Parser.exe
file f:\dd\vctools\crt_bld\Self_x86\crt\src\fopen.c
Line 53

Expression: (file!=NULL)”

then it opens a file “dbghook.c” in visual studio

  • 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-21T18:28:49+00:00Added an answer on May 21, 2026 at 6:28 pm

    textFileCopy(false, false) is being implicitly converted to textFilecopy(NULL, NULL) and when you attempt to open an ifstream with a NULL filename, you get the assertion you’re seeing.

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

Sidebar

Related Questions

I'm experimenting with internationalization by making a Hello World program that uses properties files
I just installed Ubuntu and tried making the famed Hello World program to make
I am working on a program that encodes a file based on a supplied
Hello I am making a simple program which is taking input from user and
hello there i am making a text editor in Tkinter (python) and so i
Hello I am compiling a program with make but I get the error of
Hello I am working with a simulator that uses rcS scripts to boot, this
I'm making a C Assessment Program through Java, which has a bunch of programming
I have a problem compiling Haskell programs, that import the Text.Regex.Posix module. I have
I have the following problem. Let's take the input (wikitext) ======hello((my first program)) world======

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.