Convert C++ string to C char*
I use a StringIntMap in my C++ programm, it's defined like this:
typedef map<string,int> StringIntMap;
Now when I am iterating though this map, I want to use the strstr() function to search for a substring in the keys of the map. This part of the program looks like that:
StringIntMap::iterator q;
StringIntMap ph;
for (q=ph.begin();q!=ph.end();++q) {
if (strstr(q->first,k)) {r=true;}
}
k is another string. The problem is, strstr() needs char* !!
How do I convert the string type to a char* pointer that strstr can use?
|