<div><br clear="all">
<p># This program emulates the diff command of UNIX</p>
<p>import sys<br>from stringCompare import stringcmp # this is a module which has stringcmp function that compares two strings</p>
<p>fname1 = raw_input("Enter a file name to be read:\t")</p>
<p>fname2 = raw_input("Enter a file name to be read:\t")</p>
<p> </p>
<p>fd1 = open(fname1,"r")<br>fd2 = open(fname2,"r")</p>
<p><br>done = 0<br>line_counter = 0</p>
<p><br>while not done:<br> aLine1 = fd1.readline()<br> aLine2 = fd2.readline()<br> <br> if (aLine1 == "" or aLine2 == ""): # test whether you have reached the end of file<br> done = 1
<br> <br> else:<br> <br> line_counter += 1 # get the line number<br> string1 = aLine1.split() # split the line into a list containing words<br> string2 = aLine2.split
()<br> <br> len1 = len(string1)<br> len2 = len(string2)<br> if len1 > len2:<br> t = len1<br> else:<br> t = len2<br> i = 0<br> while (i < t):<br> cmp_res = stringcmp(string1[i],string2[i])
<br> if cmp_res != 0:<br> column = i<br> done = 1<br> <br>print "The difference is lies in the ", line_counter ,"line and column ", column</p></div>
<div> </div>
<div> </div>
<div> </div>
<div>Can someone help me with what is wrong in this code; when I am running it gets stuck.</div>
<div> </div>
<div>thanks in anticipation.</div>
<div>Regards,</div>
<div>Asrar</div>
<div> </div>
<div> </div>
<div> </div>
<div> </div>
<div><br>-- <br>To HIM you shall return. </div>