C Program to Compare two Text or Data files


Compare two files in a C Programming

Program : C Program to Compare two text/data files in C Programming

  • Check whether two files are identical or not.

Explanation :

  1. Firstly Declare two file pointers for two files.
  2. Open two files in read mode.
  3. Now Inside while loop read both files character by character.
  4. Check both characters whether they are equal or not.
  5. If inside if statement ch1 = EOF and ch2=EOF then both files are said to be equal otherwise both files are non identicle.