Re: Can any body tell me how to find duplicate lines in C



RSBakshi@xxxxxxxxx wrote:
> Can any body tell me how to find duplicate lines in C
>
> i have tried to find using Binary tree and Text files but not suceeded
> .
>
> It works for Word but not for lines
>
> please help me
>

Your question isn't really a "C" question, but more an algorithm one.
comp.programming might be a better place to ask it.

Assuming you can slurp the whole file into an array (i.e. assuming
you don't need to work on really big files, etc), you could use
the following simple approach.

1) slurp file into array (look at fgets, or cbfalconer's ggets code)
2) sort the array (look at quicksort)
3) iterate through the array, comparing each line to the next (look at
strcmp)

I expect is a good enough approach. Write some code and come
back with it if you have problems.

> you can write suggetion to my email : rsbakshi@xxxxxxxxx

No thanks, I prefer to post :p

-David

.