-
C compare question.
What function would you guys recommend to use for comparing files. Ex. I have a file called macs1 and another called macs2 each file holds a list of mac addresses in it and nothing else. What I want to do is compare the 2 files and whichever mac address shows up in both files output it to a new file. Thanks
-
there is no C function that will do that for you - just read the addresses into two arrays, set up two nested loops and do the comparison.
Code:
for(int i = 0; i < a_size; ++i) {
for(int j = 0; j < b_size; ++j) {
if(a[i] == b[j]) {
// send to the file
}
}
}
that won't prevent duplicates of course...
-
The unix/linux 'comm' utility will do this for you