CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: String Help

  1. #1
    Join Date
    Mar 2011
    Posts
    1

    String Help

    Ok so I am writing a program that requires me to enter a long list of names and save it as a string. So my string contains a list of about 150 names. My question is how do I separate these names, one at a time to sort them. Im creating a binary tree sorter, i want to have the program read one name then create a new node for it then add another name and create a new node for that and so on. How do i go about doing this? Thanks in advance for any help.

  2. #2
    Join Date
    Apr 1999
    Posts
    27,449

    Re: String Help

    Quote Originally Posted by DtadaC99 View Post
    Ok so I am writing a program that requires me to enter a long list of names and save it as a string. So my string contains a list of about 150 names. My question is how do I separate these names, one at a time to sort them.
    Your description is not clear.

    What do you mean by "long list of names"? The names are just one giant string? If so, what are the characters that tells you where one name starts and ends?
    Im creating a binary tree sorter, i want to have the program read one name then create a new node for it then add another name and create a new node for that and so on. How do i go about doing this? Thanks in advance for any help.
    Code:
    #include <map>
    #include <string>
    
    struct Node
    {  
       // whatever
    };
    
    typedef std::map<std::string, Node> StringToNodeMap;
    When you add a string to the map, it

    1) Sorts the name,
    2) Adds a node.

    Everything is done for you if you use the proper container class.

    Regards,

    Paul McKenzie

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured