hello dear friends
I have written a simple file merger and the code has been shown as bellow but I get an error that I do not how to solve it please guide me .

Code this small can easily be embedded into your post, so in future, do it :icon_wink:

#define _AFXDLL

#include <fstream>
#include <string>
#include <Cstringt.h>
#include <iostream>
#include <direct.h>
#include <afxv_w32.h>

using namespace std;

int main()
{
	string line1, line2 ; 
	string end_str ;
	CFileFind  finder;
	bool finding = finder.FindFile ();
	bool firstFile=1;
	bool condition;
//-------------------------------------------------------------	
	end_str = "<ENDFILE;" ;
	condition= 0;
	while (finding)
    {
	    finding = finder.FindNextFile();
		Cstring title = finder.GetFileName();
		ifstream fin (title);
		if(!fin) 
		{
			cout<< "cannot open input file \n";
			return 1;
		}	
		ofstream fout ("merge.cf"); 
		if (!fout) 
		{	
			cout<< "cannot open output file .\n";
			return 1;
		}
//..............................................................
		if(firstFile)
		{
			while (!fin.eof())
			{
				getline (fin,line1);
				getline (fin,line2);
				if (end_str==line2)
					condition=1;
				else 
					condition=0;
				if(!condition)
					fout<<line1<<'\n';
				else
					fout<<line1;
			}
			firstFile=0;
		}
		else 
		{
			getline (fin,line1);
			fout<<'\n';
			while (!fin.eof())
			{
				getline (fin,line1);
				fout<<line1<<'\n';
			}
		}
		fout.close();
	}
	finder.Close ();
	return 0;
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.