STL List

This is a discussion on STL List within the C++ Programming forums, part of the General Programming Boards category; if i have a file with names in it in this manner: John : Bob Mike : Joe Mark : ...

  1. #1
    Registered User
    Join Date
    Sep 2002
    Posts
    64

    STL List

    if i have a file with names in it in this manner:

    John : Bob
    Mike : Joe
    Mark : John
    Bob : Ted

    I want the program to read in the file and seperate the names, that is done. However, I am stuck on how to insert the names in to a list based on whether they have been previously read. Basically, I want to comprise little lists and make one big list.

    Here are the 3 situations I do not know how to code:

    1. if one name appears in an existing little list, add it to the other list that has that name as well.

    2. if both names appear in an existing list, connect the two lists.

    3. if neither name appears in a list, form a a new list with the two names.

    I need an iterator to do this, but I am unsure how to code the IF statements?

    Please, any help and advice is greatly appreciated!

    Sincerely,
    Josh

  2. #2
    geek SilentStrike's Avatar
    Join Date
    Aug 2001
    Location
    NJ
    Posts
    1,141
    Can you clarify your problem? Do you simply want to make a list of names from the file with every name appearing only once? Or is it some more complex structure that you want the final structure to have? Can you give the results of that example?
    Prove you can code in C++ or C# at TopCoder, referrer rrenaud
    Read my livejournal

  3. #3
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,659
    Sounds like homework. Post your code with specific problems, and we'll be glad to help.

    And be sure to use code tags.



    ITSA
    Socket Library!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Link List math
    By t014y in forum C Programming
    Replies: 17
    Last Post: 02-20-2009, 05:55 PM
  2. Following CTools
    By EstateMatt in forum C Programming
    Replies: 5
    Last Post: 06-26-2008, 10:10 AM
  3. Simple list code
    By JimpsEd in forum C Programming
    Replies: 1
    Last Post: 05-24-2006, 02:01 PM
  4. instantiated from here: errors...
    By advocation in forum C++ Programming
    Replies: 5
    Last Post: 03-27-2005, 08:01 AM
  5. Contest Results - May 27, 2002
    By ygfperson in forum A Brief History of Cprogramming.com
    Replies: 18
    Last Post: 06-18-2002, 01:27 PM

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