mercredi 6 juillet 2016

find string in map function c++


I've never used map lib in C++ and I'm implementing a graph adding cities on it, and this is what I'm doing:

I read a city from a txt file, then I look for it in mymap. If I find it, don't need to add in the graph and in the map, if not, I create a integer key for it,put in the map and then add in the graph.

The problem is, I don't know how to find a string in mymap, the find function works just for char,right?

mymap is

map<int,string> cities;

example cities["New York"] = 1; cities["Brazilia"] = 2;


Aucun commentaire:

Enregistrer un commentaire