Thread: Simply C++ command line utility to compare files; what classes to use?

  1. #1
    Registered User
    Join Date
    May 2009

    Simply C++ command line utility to compare files; what classes to use?

    I have decided that I want to write a simple command line utility to load two files into some C++ class/ADT.

    The entries will be package names and the will be different with no duplications. The data from two files files need to be compare and entries missing from being in both files displayed.

    The files will contain package_name [WHITE_SPACE] package_version.

    I will be ignore package_version and just loading package_name into the ADT.

    I just wish a list of classes to check out in doing the ADT; right now the only thing that comes to mind is vector. But, I am still trying to learn C++ and this project seems both useful and simple an a good thing to try.

    My last project was too complex and I lost interest when other real world things happened.

    I will be using MinGW64 GCC 12.1 and I do not wish to use third party libs like Boost.

    Edit: If I was using C, I would use a sorted link list.

    Thank you all for your past help.

    Tim S.
    Last edited by stahta01; 11-12-2022 at 12:00 PM.
    "...a computer is a stupid machine with the ability to do incredibly smart things, while computer programmers are smart people with the ability to do incredibly stupid things. They are,in short, a perfect match.." Bill Bryson

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    The edge of the known universe
    I think I'd use std::set -

    Read the first file into set 1.

    When reading the 2nd file, do one of two things
    - if it's in set1, it's common to both (so remove it from set1)
    - otherwise, add it to set2

    The end result is two sets containing only items that appear in one file.
    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. making a WC utility on command line
    By Swoosh in forum C Programming
    Replies: 1
    Last Post: 04-08-2021, 10:01 PM
  2. input files using command line arguments possible?
    By narniat in forum C Programming
    Replies: 19
    Last Post: 12-19-2018, 06:02 PM
  3. Replies: 12
    Last Post: 05-15-2017, 07:24 AM
  4. Replies: 0
    Last Post: 09-05-2016, 09:04 PM
  5. Handling multiple input files from command line
    By cnfwriter in forum C Programming
    Replies: 13
    Last Post: 08-25-2008, 08:07 AM

Tags for this Thread