C compare question.

This is a discussion on C compare question. within the C Programming forums, part of the General Programming Boards category; What function would you guys recommend to use for comparing files. Ex. I have a file called macs1 and another ...

  1. #1
    Registered User
    Join Date
    Aug 2004
    Posts
    5

    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
    Location
    Waterloo, Texas
    Posts
    5,708
    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...
    Last edited by Sebastiani; 09-08-2004 at 09:00 PM.
    Code:
    #include <cmath>
    #include <complex>
    bool euler_flip(bool value)
    {
        return std::pow
        (
            std::complex<float>(std::exp(1.0)), 
            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
    Location
    The edge of the known universe
    Posts
    32,830
    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.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Question...
    By TechWins in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 07-28-2003, 10:47 PM
  2. Replies: 7
    Last Post: 04-13-2003, 11: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 Cprogramming.com
    Replies: 5
    Last Post: 12-24-2001, 01:47 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21