How to check duplicate line in text file?

This is a discussion on How to check duplicate line in text file? within the C++ Programming forums, part of the General Programming Boards category; I want to chek duplicate line in text file Example: If in "1.txt" has this data inside 50B82D3F9D3 2C051C76C7D 5804EBB2BB8 ...

  1. #1
    Registered User
    Join Date
    Jan 2002
    Posts
    68

    Smile How to check duplicate line in text file?

    I want to chek duplicate line in text file

    Example:

    If in "1.txt" has this data inside
    50B82D3F9D3
    2C051C76C7D
    5804EBB2BB8
    559AAC90CEE
    DA64B9F10CC
    B9A6A9866A9
    AFF45E93F23
    .
    .
    .
    .
    45788887454
    B9A6A9866A9

    This above text file has duplicate line

    "B9A6A9866A9"

    I want to write proram to check duplicate line.
    Do you know how to do that? (Now I can use CStdioFile (ReadString, WriteString) and show Messagebox but not have idea to do that.)

    Thank you for your answer.

  2. #2
    Registered User
    Join Date
    Jan 2002
    Posts
    68
    I want to show message box which display message duplicate or not duplicate.

  3. #3
    Rebooted Inquirer's Avatar
    Join Date
    Apr 2002
    Posts
    281
    first, in the future, you may not want to ask if we know how to do it, as some smart alec will just post a "yes" for you. It could be rephrased "could someone help walk me through finding out how to do it" etc. Prelude posted a (really good) article/thread in the FAQ forum, and if you follow the rules/examples laid out in there, you will probably need a personal secretary to filter the incoming help (exagerating, but you get the point).

    Now, to the question. YOu could store them all in an STL containor, and use one of the functions there (i forget what it is, sorry) to delete all replica lines, or you could use another one to replace them all. Sorry that i can't explain exactly how to do this too well, but i believe others could help you should you want to take this road.
    Compilers:
    GCC on Red Hat 8.1 (Primary)
    GCC on Mac OS X 10.2.4 (Secondary)

    Others:
    MinGW on XP

  4. #4
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    A binary tree sounds like it might do the trick....
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 19
    Last Post: 05-30-2007, 05:47 PM
  2. A bunch of Linker Errors...
    By Junior89 in forum Windows Programming
    Replies: 4
    Last Post: 01-06-2006, 01:59 PM
  3. reading a text file printing line number
    By bazzano in forum C Programming
    Replies: 4
    Last Post: 09-16-2005, 10:31 AM
  4. struct question
    By caduardo21 in forum Windows Programming
    Replies: 5
    Last Post: 01-31-2005, 03:49 PM
  5. Possible circular definition with singleton objects
    By techrolla in forum C++ Programming
    Replies: 3
    Last Post: 12-26-2004, 09:46 AM

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