473,395 Members | 1,774 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Compare Two Files Char By Char.

HI guy
I am using This Code For Compare Two Files at Button Click
Event. if user select Data from richtextbox1 and click the Compare
Button then it will match with second richtextbox2 data. this code is
working but not according to my requirement. my requirement is if user
select data from richtextbox1 and click the button then it should be
match with richtextbox2 and if there is no matching then highlight that
word or line by color change.
plz help me i gave up myself
string[,] line = new string[500, 2];
string[,] line1 = new string[500, 2];
char[] fullstop = new char[2];
int i=0;
for (i = 0; i < 500; i++)
{
line[i,1] = "0";
line1[i,1]= "0";
}
fullstop[0] = '.';
fullstop[1] = '?';

string error=" ";

string[] AllLine = new string[500];
AllLine = richTextBox1.SelectedText.Split(fullstop);

string[] AllLine1 = new string[500];
AllLine1 = richTextBox2.SelectedText.Split(fullstop);

i = 0;

while (AllLine[i] != "" && AllLine1[i] != "")
{
line[i, 0] = AllLine[i];
line1[i, 0] = AllLine1[i];
string[] word = new string[50];
string[] word1 = new string[50];
int j=0;
for (j = 0; j < 50; j++)
{
word[j] = null;
word1[j] = null;
}
fullstop[0] = ' ';
word = line[i, 0].Split(fullstop);
word1 = line1[i, 0].Split(fullstop);
int len,len1,min;
len1 = word1.Length;
len = word.Length;

if (word.Length word1.Length)
min=word1.Length;
else
min=word.Length;

j = 0;

while (j < min)
{
if (word[j] != null && word1[j] != null)
{
if (word[j] != word1[j])
{
error = error + " " + word1[j];
}
}
j++;
}
if (word1.Length word.Length)
{
for (; j < word1.Length; j++)
error = error + " " + word1[j];// prints blah
}
i++;
}
richTextBox3.Text = error;

Aug 23 '06 #1
2 2422
Hi,

Are you getting an error?
--
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Twinkle" <he*************@gmail.comwrote in message
news:11**********************@m73g2000cwd.googlegr oups.com...
HI guy
I am using This Code For Compare Two Files at Button Click
Event. if user select Data from richtextbox1 and click the Compare
Button then it will match with second richtextbox2 data. this code is
working but not according to my requirement. my requirement is if user
select data from richtextbox1 and click the button then it should be
match with richtextbox2 and if there is no matching then highlight that
word or line by color change.
plz help me i gave up myself
string[,] line = new string[500, 2];
string[,] line1 = new string[500, 2];
char[] fullstop = new char[2];
int i=0;
for (i = 0; i < 500; i++)
{
line[i,1] = "0";
line1[i,1]= "0";
}
fullstop[0] = '.';
fullstop[1] = '?';

string error=" ";

string[] AllLine = new string[500];
AllLine = richTextBox1.SelectedText.Split(fullstop);

string[] AllLine1 = new string[500];
AllLine1 = richTextBox2.SelectedText.Split(fullstop);

i = 0;

while (AllLine[i] != "" && AllLine1[i] != "")
{
line[i, 0] = AllLine[i];
line1[i, 0] = AllLine1[i];
string[] word = new string[50];
string[] word1 = new string[50];
int j=0;
for (j = 0; j < 50; j++)
{
word[j] = null;
word1[j] = null;
}
fullstop[0] = ' ';
word = line[i, 0].Split(fullstop);
word1 = line1[i, 0].Split(fullstop);
int len,len1,min;
len1 = word1.Length;
len = word.Length;

if (word.Length word1.Length)
min=word1.Length;
else
min=word.Length;

j = 0;

while (j < min)
{
if (word[j] != null && word1[j] != null)
{
if (word[j] != word1[j])
{
error = error + " " + word1[j];
}
}
j++;
}
if (word1.Length word.Length)
{
for (; j < word1.Length; j++)
error = error + " " + word1[j];// prints blah
}
i++;
}
richTextBox3.Text = error;

Aug 23 '06 #2
HI
Yes I am getting many errors.first it's not comparing
Completly.becaz i want to compare char by char and find the incorrect
words then highlight that incorrect words in richtextbox2.there is one
more probs it is not taking Space.
Ignacio Machin ( .NET/ C# MVP ) wrote:
Hi,

Are you getting an error?
--
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Twinkle" <he*************@gmail.comwrote in message
news:11**********************@m73g2000cwd.googlegr oups.com...
HI guy
I am using This Code For Compare Two Files at Button Click
Event. if user select Data from richtextbox1 and click the Compare
Button then it will match with second richtextbox2 data. this code is
working but not according to my requirement. my requirement is if user
select data from richtextbox1 and click the button then it should be
match with richtextbox2 and if there is no matching then highlight that
word or line by color change.
plz help me i gave up myself
string[,] line = new string[500, 2];
string[,] line1 = new string[500, 2];
char[] fullstop = new char[2];
int i=0;
for (i = 0; i < 500; i++)
{
line[i,1] = "0";
line1[i,1]= "0";
}
fullstop[0] = '.';
fullstop[1] = '?';

string error=" ";

string[] AllLine = new string[500];
AllLine = richTextBox1.SelectedText.Split(fullstop);

string[] AllLine1 = new string[500];
AllLine1 = richTextBox2.SelectedText.Split(fullstop);

i = 0;

while (AllLine[i] != "" && AllLine1[i] != "")
{
line[i, 0] = AllLine[i];
line1[i, 0] = AllLine1[i];
string[] word = new string[50];
string[] word1 = new string[50];
int j=0;
for (j = 0; j < 50; j++)
{
word[j] = null;
word1[j] = null;
}
fullstop[0] = ' ';
word = line[i, 0].Split(fullstop);
word1 = line1[i, 0].Split(fullstop);
int len,len1,min;
len1 = word1.Length;
len = word.Length;

if (word.Length word1.Length)
min=word1.Length;
else
min=word.Length;

j = 0;

while (j < min)
{
if (word[j] != null && word1[j] != null)
{
if (word[j] != word1[j])
{
error = error + " " + word1[j];
}
}
j++;
}
if (word1.Length word.Length)
{
for (; j < word1.Length; j++)
error = error + " " + word1[j];// prints blah
}
i++;
}
richTextBox3.Text = error;
Aug 23 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Nathan Rosaaen | last post by:
I want to be able to easily see what changes were made from original to updated sentences (words added/removed/changed). I'm not too concerned about speed, just looking for something. The compared...
13
by: MrCoder | last post by:
Hey guys, my first post on here so I'll just say "Hello everbody!" Ok heres my question for you lot. Is there a faster way to compare 1 byte array to another? This is my current code //...
4
by: Siemel Naran | last post by:
How to compare if two files are identical? I wrote the following: bool comparefiles(const std::string& lhs, const std::string& rhs) { std::ifstream lhsfile(lhs.c_str()); std::ifstream...
8
by: Earl Purple | last post by:
On VC++.NET it is implemented like this static int __cdecl compare ( const _Elem *_First1, const _Elem *_First2, size_t _Count ) { // compare [_First1, _First1 + _Count) with [_First2, ...)...
8
by: Sharon | last post by:
hi, I want to compare character, if the string contains character "-" then it will print Hello on the screen however, neither method (1) nor method (2) work in the code below: so what the correct...
12
by: chellappa | last post by:
hi brotthers and sisters, i have lot of doubts in c programming 1.how to compare the char pointer with a char pointer in c programming.. 2.how to compare the char array with a char pointer...
11
by: jamx | last post by:
I need to compare the following values: char buf; /* buf is filled using COMport here... */ if (buf == 0x85) { /* do something */ }
9
by: Martoon | last post by:
I want to instantiate an STL map with my own compare function, and I want to pass a parameter to the compare function that will be stored and used for all comparisons in that map instance. As an...
5
by: S S | last post by:
Hi I have a requirement where I am declaring a map within a class. class abc { map <void*, void*mMap; // I do not pass compare struct here. .... }; Here I am not passing compare function,...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.