C Program to compare two files

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • anithas
    New Member
    • Feb 2007
    • 8

    #1

    C Program to compare two files

    I need to write a C program to compare two files not in the same sequence.

    ie. Take one line from first file....compare with all lines in second file....If there is no match....put it in a third file

    If there is any match ...leave that line...and go to the second line in the first file....again compare with all lines in second file.

    Continue the same procedure till we reach the end of the first file.

    kindly let me know if any useful links are there related to this which I can refer to
  • JosAH
    Recognized Expert MVP
    • Mar 2007
    • 11453

    #2
    Originally posted by anithas
    I need to write a C program to compare two files not in the same sequence.

    ie. Take one line from first file....compare with all lines in second file....If there is no match....put it in a third file

    If there is any match ...leave that line...and go to the second line in the first file....again compare with all lines in second file.

    Continue the same procedure till we reach the end of the first file.

    kindly let me know if any useful links are there related to this which I can refer to
    I'd say check out the following functions:
    1) fopen
    2) fclose
    3) fseek
    4) fgets
    5) fputs
    6) strcmp

    Sprinkle in two nested loops and voila.

    kind regards,

    Jos

    Comment

    Working...