Hi Programmer, I'm a beginner ans i'm asking how to know that two files have exactly the same content for security reasons and how to compare them? N.B: the two files don't have necessarly the same name or directory. Thanks a lot .
posted 14 years ago
You could set up a loop and read a char from each at a time, similar to: (PSEUDOCODE) areSame = true while not end-of-file Char1 = read char from file1 Char2 = read char from file2 If not char1 = char2 then areSame = false end while (END PSEUDOCODE) If we get to this point and areSame is true we know the two files are identical. This basic algorithm could be optimised, but its best to get a basic system working first before tweaking it. Hope this helps, A