help

This is a discussion on help within the C Programming forums, part of the General Programming Boards category; ok i need a little c app that will cross check 2 text files and make changes to one of ...

  1. #1
    Registered User
    Join Date
    Mar 2005
    Posts
    2

    Question help



    ok i need a little c app that will cross check 2 text files and make changes to one of those files accordingly.

    i have one text file with all the file names i SHOULD have, and another text file with all the names of the files i DO have. heres a few lines from each respectivly;

    first file:
    1001-C-0012
    1001-C-0013
    1001-C-0014
    1001-C-0015
    1001-C-0016
    1001-C-0017
    1001-C-0020
    1001-C-0021
    1001-C-0022
    1001-C-0023
    1001-C-0024
    1001-C-0025
    1001-C-0026
    1001-C-0027
    1001-C-0028
    1001-C-0029
    1001-C-0030

    second file:
    1001c0012r1.tif
    1001c0013r2.tif
    1001c0015r1.tif
    1001c0016r1.tif
    1001c0017r1.tif
    1001c0020r2.tif
    1001c0021r1.tif
    1001c0022r1.tif
    1001c0025r1.tif
    1001c0026r1.tif
    1001c0027r4.tif
    1001c0029r5.tif
    1001c0030r3.tif

    so if you notice the first 9 characters from the second file are the names from the first but with a suffix rX.tif. the rX being the revision number which isnt important. But if you compare the file names you will notice that the second file is missing some of the names from the first file.. I need an app that will compare the files and if the name is missing from the second file it will add a new line, making a space for where the name should be so when i compare them side by side it will look like:

    1001-C-0012 1001c0012r1.tif
    1001-C-0013 1001c0013r2.tif
    1001-C-0014
    1001-C-0015 1001c0015r1.tif
    1001-C-0016 1001c0016r1.tif
    1001-C-0017 1001c0017r1.tif
    1001-C-0020 1001c0020r2.tif
    1001-C-0021 1001c0021r1.tif
    1001-C-0022 1001c0022r1.tif
    1001-C-0023
    1001-C-0024
    1001-C-0025 1001c0025r1.tif
    1001-C-0026 1001c0026r1.tif
    1001-C-0027 1001c0027r4.tif
    1001-C-0028
    1001-C-0029 1001c0029r5.tif
    1001-C-0030 1001c0030r3.tif

    pretty straight forward eh? but i am a bit off a noob when it comes to programming. if anyone can just gimme a bit of a hand, a few lines off code and such ill be able to throw something together. The text files are 3300+ lines so i dont want to have to go down manualy and do it.

    Thanks

  2. #2
    Registered User
    Join Date
    Mar 2004
    Posts
    161
    how can we help you if you don't post your bugged code?

    anyway, use better titles for your thread next time
    This forum is the best one I've ever seen. Great ppl, great coders

  3. #3
    Registered User
    Join Date
    Mar 2005
    Posts
    2
    i dont actually have any code, hence my reason to post..

    i just need help to get started, ie functions and methods ill need and how big it would be, would it be easy enough to do quickly? and so on..

  4. #4
    Registered User
    Join Date
    Mar 2004
    Posts
    161
    it's easy, you just have to fopen and read the files, read line by line, cut the longer and strcmp them.. and of course write the output somewhere in a file
    This forum is the best one I've ever seen. Great ppl, great coders

Popular pages Recent additions subscribe to a feed

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