944,079 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Unsolved
  • Views: 1611
  • C++ RSS
Feb 27th, 2006
0

Address book problems....Any advice???

Expand Post »
ok im stuck here atm...what im trying to do is to have the program compile to run in windows..and i have to type in the name...and the program goes into the database and finds the address and puts it onto the screen...just like an address book..

So heres my code..anyone have some advice or tips?
:mrgreen:

C++ Syntax (Toggle Plain Text)
  1. #include <map>
  2. #include <string>
  3. #include <iostream>
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8. map<string,string> addressbook;
  9. pair<string,string> p1("Eric","415 East Arlington");
  10. addressbook.insert(p1);
  11.  
  12. typedef pair<string,string> entry;
  13. map<string,string>::iterator iter;
  14. cout << "What is Eric's address?" << endl;
  15. cout << "" << addressbook["Eric"] << endl;
  16. cout << endl;
  17.  
  18. char response;
  19. std::cin >> response;
  20. return 0;
  21.  
  22. }
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Whodey is offline Offline
10 posts
since Feb 2006
Feb 27th, 2006
0

Re: Address book problems....Any advice???

does it work the way it is intended? If yes, then why fix something that ain't broken? But its obvous that it doesn't do what you want it to do.

What kind of database are you supposed to use? MySql, MS-Access, simple flat-text file? or something else?
Sponsor
Team Colleague
Featured Poster
Reputation Points: 5608
Solved Threads: 2282
Retired and Enjoying Life
Ancient Dragon is offline Offline
21,957 posts
since Aug 2005
Feb 28th, 2006
0

Re: Address book problems....Any advice???

Quote originally posted by Ancient Dragon ...
does it work the way it is intended? If yes, then why fix something that ain't broken? But its obvous that it doesn't do what you want it to do.

What kind of database are you supposed to use? MySql, MS-Access, simple flat-text file? or something else?

well what i mean is that the code does work...im just trying to convert it to a address book sorta like.....

u have to type in the name and it finds the there address and pops it up under the name.....sorta like basic...

If im not clear then idk :rolleyes:
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Whodey is offline Offline
10 posts
since Feb 2006
Feb 28th, 2006
0

Re: Address book problems....Any advice???

how do you want to store the data -- or do you want to type evetything in each time you run the program?

Use a loop so that you can enter more than one name/address pair during the same instance of the program.

after asking for Eric's address, use a variable and cin to get the address from the keyboard.
Sponsor
Team Colleague
Featured Poster
Reputation Points: 5608
Solved Threads: 2282
Retired and Enjoying Life
Ancient Dragon is offline Offline
21,957 posts
since Aug 2005
Feb 28th, 2006
0

Re: Address book problems....Any advice???

Quote originally posted by Ancient Dragon ...
how do you want to store the data -- or do you want to type evetything in each time you run the program?

Use a loop so that you can enter more than one name/address pair during the same instance of the program.

after asking for Eric's address, use a variable and cin to get the address from the keyboard.

was thinking about storeing it the first time...and thanks for the tips man...it really helps alot
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Whodey is offline Offline
10 posts
since Feb 2006

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: Urgent Help
Next Thread in C++ Forum Timeline: Creating dynamic arrays





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC