-
March 21st, 2011, 11:34 PM
#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.
-
March 22nd, 2011, 03:47 AM
#2
Re: String Help
Originally Posted by DtadaC99
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|