Sign in to follow this  

c++ question

This topic is 4105 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Not exactly - like Evil Steve says, that's impossible.

What you can do is using an associative container that maps strings to other strings:


std::map<std::string,std::string> string_map;

string name;
string_map[(what name equals)] = name;
string_map[(what name equals)];

Share this post


Link to post
Share on other sites
i'm trying to make something like a phone book in a console window and i need it to be able to make a new string for a name and a number and then be able to check its number just by writing the name of the person tell me if this is possible

Share this post


Link to post
Share on other sites
tell me if i'm missing the point but i mean if you don't now the names at the begining you put every thing in later (names and numbers)

could i make it read all the files in a folder meaning everytime you put in a name it saves it as a .txt file or something and then you type in the name and it will write everything in that file (name and number)

Share this post


Link to post
Share on other sites
Quote:
Original post by gabriel76
could i make it read all the files in a folder meaning everytime you put in a name it saves it as a .txt file or something and then you type in the name and it will write everything in that file (name and number)


Yes. Though it would be more practical to have one .txt per 'phonebook'. The textfile could be laid out like so:

Peron's name
phone number
Other person's name
other phone number
Another person's name
another phone number

Ect. This requires only one file name (which is easier to do than to get all file names in a directory, which requires 3rd party libraries). Then you'd have a while loop that reads lines in until one of them is EOF (end of file, IYDK).

Share this post


Link to post
Share on other sites

This topic is 4105 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this