OK well ive been trying to get this..and its just not working the way it should work.... :cry:

The this is i got the cin in there...to put the input up in the code but it wont find where the addreess is....like i should be able to say...Erics address is?...and then the address should come up...but all it does is exit...im confused and frustated about it..but thats what c++ is... :D

#include <map> 
#include <string>
#include <iostream>
using namespace std;

int main() 
{
    map<string,string> addressbook;
    pair<string,string> p1("Eric","415 East Arlington");
    addressbook.insert(p1);
    
typedef pair<string,string> entry;
int a;
    map<string,string>::iterator iter;
    cin  >> a;
    cout << " " <<a << addressbook["Eric"] << endl;
    cout << endl;

    char response;
    std::cin >> response;
    return 0;

}

I'm not sure what language it is you're speaking, but it reminds me of Gibberish. Your code has a lot of unnecessary junk in it that serves no real purpose. Tell me what your problem is with this:

#include <map> 
#include <string>
#include <iostream>

using namespace std;

int main() 
{
  map<string,string> addressbook;
  pair<string,string> p1("Eric","415 East Arlington");

  addressbook.insert(p1);
  cout << "Eric's address is " << addressbook["Eric"] << endl;

  cin.get(); // Pause program
}

I'm reasonably sure that your input calls were the problem, but you expressed it in such a chaotic way that I can't be sure what your real problem is.

I'm not sure what language it is you're speaking, but it reminds me of Gibberish. Your code has a lot of unnecessary junk in it that serves no real purpose. Tell me what your problem is with this:

I'm reasonably sure that your input calls were the problem, but you expressed it in such a chaotic way that I can't be sure what your real problem is.

Gibberish yah thats it :lol:

but u know how the program compiles comes out like....

Eric address is 415 east arlington...

what im trying to get is to Type in Eric Address is?...
and tthen after i hit enter....his address comes up...

#include <map> 
#include <string>
#include <iostream>

using namespace std;

int main() 
{
  map<string,string> addressbook;
  pair<string,string> p1("Eric","415 East Arlington");
  string name;

  addressbook.insert(p1);

  cin>> name;
  cout<< name <<"'s address is "<< addressbook[name] <<'\n';

  cin.ignore(1024, '\n'); // Ignore the rest
  cin.get(); // Pause program
}

What you need to do is parse the input string so that you can find the name to use as your key. That's surprisingly difficult if you give the user the option of free form input (ie. they can type whatever they want). You would be better off asking for specific information to increase your chances of getting something usable.

What you need to do is parse the input string so that you can find the name to use as your key. That's surprisingly difficult if you give the user the option of free form input (ie. they can type whatever they want). You would be better off asking for specific information to increase your chances of getting something usable.

Yah i know it will be difficult in that sence. :eek:

But right now im trying to start small then get up to a database..

I really Consider what ur doing on helping me and Thanks for the Help :cheesy:

just started a two weeks ago so i think im doing ok =D thanks agains

>But right now im trying to start small then get up to a database..
Even databases have a strict method for doing queries because it's easier to throw an error for bad syntax than to try and parse whatever garbage the user tries to give you. ;)

This article has been dead for over six months. Start a new discussion instead.