Thread: C compare question.

  1. #1
    Registered User
    Join Date
    Aug 2004

    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

  2. #2
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Waterloo, Texas
    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.

    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...
    Last edited by Sebastiani; 09-08-2004 at 08:00 PM.
    #include <cmath>
    #include <complex>
    bool euler_flip(bool value)
        return std::pow
            std::complex<float>(0, 1) 
            * std::complex<float>(std::atan(1.0)
            *(1 << (value + 2)))
        ).real() < 0;

  3. #3
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    The edge of the known universe
    The unix/linux 'comm' utility will do this for you
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Question...
    By TechWins in forum A Brief History of
    Replies: 16
    Last Post: 07-28-2003, 09:47 PM
  2. Replies: 7
    Last Post: 04-13-2003, 10:53 PM
  3. opengl DC question
    By SAMSAM in forum Game Programming
    Replies: 6
    Last Post: 02-26-2003, 09:22 PM
  4. Question about linked lists.
    By cheeisme123 in forum C++ Programming
    Replies: 6
    Last Post: 02-25-2003, 01:36 PM
  5. Question, question!
    By oskilian in forum A Brief History of
    Replies: 5
    Last Post: 12-24-2001, 01:47 AM