( Index )
Month

Brief Information about the March '04 CSIG Meeting

V Diff - A File Comparer

By shankarp

V Diff Header from Web Site

Welcome to the CSIG, a Special Interest Group of the ACGNJ. The subject for this month is an interesting program that I discovered on www.codeproject.com. The program consists of a number of parts.
1) A Windows based front end program for filename input.
2) A console based program for comparing two text files.
3) A sophisticated comparison algorithm.
4) An output strategy which produces HTML text.
5) The resulting analysis displayed by a browser.

Here's a sample of the output:

Sample Program Output

The plan for the meeting will be for all of us to discover the techniques of VC++ programming used by the author. Regardless of the progress that we make on Tuesday night, you will be left with a valuable utility for your toolbox.

Sample Code

#include "..\CmpMngr.h"
#include <iostream>

int main(int argCount, char **argArray)
{
	if (argCount < 3)
	{
		cout<<"Usage 'cmp file1 file2 [output dir]' "<<"\n";
		return 0;
	}
	else
	{
		CCmpMngr cMgr;
		std::string file1,file2,oDir;
		
		cMgr.baseFile = std::string(argArray[1]);
		cMgr.compFile = std::string(argArray[2]);
		cMgr.compare();
		if (argCount > 3) // Visual diffrence is needed
		{
			oDir = std::string(argArray[3]);
		   if (oDir[oDir.length()-1] != '\\') oDir.append(std::string("\\"));
			cMgr.print_diff_in_HTML(oDir);
		}
		cout<<"Added Lines = "<<cMgr.nAddedLines<<"\n";
		cout<<"Deleted Lines = "<<cMgr.nDeletedLines<<"\n";
		cout<<"Changed Lines = "<<cMgr.nChangedLines<<"\n";
	}
	return 1;
}

"Random Access" questions start at 7:30 Tuesday night.

SOURCE CODE

Source Code Files

For help, email me at b a r n o l d @ i e e e . o r g
Back to C++ Main Page