i need to iterate through the map and find string[i] and replace the int with the string.
eg: if map contains
hello 6
world 4
its 3
me 60
if the string is "its me hello world world hello"
output should be "3 60 6 4 4 6"
Expand|Select|Wrap|Line Numbers
- for(int i = 0 ; i < str.length() ; i++){
- it = mymap.find(str[i]); //it is iterator, mymap is map<string,int>
- myOutfile << (*it).second; //myOutfile is out stream
- }
Expand|Select|Wrap|Line Numbers
- for(itStr its = str.begin() ; its < str.end(); its++ ){
- itf = myMap.find(*its);
- myOutfile << (*itf).second;
- }
main.cpp:294: error: invalid conversion from `char' to `const char*'
main.cpp:294: error: initializing argument 1 of `std::basic_string<_CharT, _Traits, _Alloc>::basic_string(const _CharT*, const _Alloc&) [with _CharT = char, _Traits = std::char_traits<char>, _Alloc = std::allocator<char>]'
can someone please help me fix this!
thanks
drjay