| | |
map<string,string> error
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Nov 2008
Posts: 78
Reputation:
Solved Threads: 1
I need help with inserting a string for both key and value to a map.
error:
error: conversion from `std::_Rb_tree_iterator<std::pair<const std::string, std::string> >' to non-scalar type `std::_Rb_tree_iterator<std::pair<const std::string, int> >' requested
can you please help me with this.
thanks
drjay
C++ Syntax (Toggle Plain Text)
while(!myHuffFile.eof()){ string word, code; int freq; myHuffFile >> word >> freq >> code; if(word == ""){ break; }else{ _fileMap.insert(pair<string,string>(word,code)); _freqMap.insert(pair<string,int>(word,freq)); } }
error:
error: conversion from `std::_Rb_tree_iterator<std::pair<const std::string, std::string> >' to non-scalar type `std::_Rb_tree_iterator<std::pair<const std::string, int> >' requested
can you please help me with this.
thanks
drjay
•
•
Join Date: Nov 2008
Posts: 392
Reputation:
Solved Threads: 72
As written there is nothing wrong with this (except I think that you would benefit from a typedef. e.g.
However, I would guess that you have swapped the declarations of fileMap and freqMap.
It that is not the problem, please make a short test program and post that.
c++ Syntax (Toggle Plain Text)
typedef std::map<std::string,int> mTYPE; mTYPE aMap; //.... aMap.insert(mTYPE::value_type(word,i));
However, I would guess that you have swapped the declarations of fileMap and freqMap.
It that is not the problem, please make a short test program and post that.
Last edited by StuXYZ; Nov 30th, 2008 at 6:15 pm. Reason: error on code tag
![]() |
Similar Threads
- Help! STL map can not insert correctly (C++)
- Problem in inserting values in map containing vector of string (C++)
- Compilation error in graphml.cpp (C++)
- Problem in using Map (C++)
- Open In New Window Php (PHP)
- (was) STL <map> question (C++)
- Dr Scheme Tutorial (Computer Science)
- Is this due to being out of memory? (C)
- Linker Error in derived class initialization (C++)
- struct error (!?) (C)
Other Threads in the C++ Forum
- Previous Thread: helpppp
- Next Thread: How to read strings into 1D array and more?
| Thread Tools | Search this Thread |
api array arrays based binary bitmap c++ c/c++ calculator char char* class classes code coding compile compiler console conversion convert count data database delete deploy developer dll download dynamic dynamiccharacterarray email encryption error file forms fstream function functions game generator getline givemetehcodez graph gui homeworkhelp iamthwee ifstream input int java lib linker list loop looping loops map math matrix memory multiple news node number numbertoword output pointer problem program programming project proxy python random read recursion recursive reference rpg sorting string strings temperature template test text text-file tree url variable vector video visual visualstudio win32 windows winsock word wordfrequency wxwidgets





