I am creating a program to copy a text file. I have a main.cpp file which reads in a text file given by the filenamein array and then output a copy of the text file given by the filenameout array. i have this function declared in my FileUtilities.h as
bool textFileCopy(char filenamein[], char filenameout[]);
Then the FileUtilities.cpp contains
#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;
}
When I compile this I get a Visual C assertion failure. I get a dialog box titled "Microsoft Visual C++ debug library" which contains the following:
"Debug Assertion Failed!
Program: .....Parser.exe
file f:\dd\vctools\crt_bld\Self_x86\crt\src\fopen.c
Line 53
Expression: (file!=NULL)"
This error gives me 3 options: Abort, Retry or Ignore. Abort just stops the debug. Retry brings up a message in Visual Studio which says "program.exe has triggered a breakpoint". If I click break here Visual Studio opens a file called "fopen.c" and points to line 54 in this file.
If I continue from this point Visual Studio opens another file called "dbghook.c" with a pointer to line 62.
filenameinorfilenameoutis NULL pointer.. Show us how you calltextFileCopy. - Kiril Kirov