[Tutor] Newbie: Help on comparing files

Danny Yoo dyoo at hkn.eecs.berkeley.edu
Wed Jan 7 17:17:03 EST 2004



On Wed, 7 Jan 2004, Isr Gish wrote:

> I looking to write a function to compare 2 files.
>
> What I want is it should take from first file a certain amount of text.
> (For example till it reaches 2 end of line marks).  Then it should
> search the "WHOLE" second file if it's there.  If not found in second
> file, write to new file this text. If found then continue with taking
> next amount of text from first file.  After the file is finished, any
> text that's in second file that was not in first file. Should be written
> to a new file.


Hi Isr,


This sounds very much like a homework problem, Any help we can give on
this will be very vague by necessity.



Do you have some example test cases to see how such a thing might work?
What happens if your first file has something like:

###
a..b..c
###

and your second file has something like:

###
b..c..d
###

if we assume that '.' is the end of line mark.  What should your output
be?





Also, what happens if you have something like:

###
alphabet soup..
###

as the first file and

###
this is a bowl of alphabet soup..
###

as the second?  (Again, assuming that '.' is the end of line mark.)




Good luck to you.




More information about the Tutor mailing list