So, i have two textboxes (defined early) and two vectors:
std::vector<TCHAR*> v1;
std::vector<int> v2;
and map:
std::map <TCHAR*, int> m1;
std::map <TCHAR*, int>:: iterator i1;
Map init:
void mapInit()
{
m1[L"one"] = 1;
m1[L"two"] = 2;
m1[L"three"] = 3;
m1[L"four"] = 4;
m1[L"five"] = 5;
m1[L"six"] = 6;
m1[L"seven"] = 7;
m1[L"eight"] = 8;
m1[L"nine"] = 9;
m1[L"ten"] = 10;
}
I should to get the word "one" from the first textbox and write it to vector 'v1' (textbox must have more words in future, so i can't to do it without vector). After, the program have to find in the map desired value by key-name:
TCHAR *zr = v1.at(0); // v1.at(0) has the word `one` atm
i1 = m1.find(zr); // want to get value `1` by key `one`
int z = i1->second; // and get it completely
I got an debug assertion error "map/set iterator not dereferencable" .. :(
If i will do all the same but will change it to L"one":
TCHAR *zr = L"one"; //
i1 = m1.find(zr);
int z = i1->second;
so it will works... Why doesn't it work with value by vector? I checked with debugger my value of vector - its 'L"one"' too! But doesn't work anyway...
NOTE: i also tried to find the word without .find() method:
TCHAR *zr = v1.at(0);
int z = m1[zr]; // - now `z` returns a null...
If i will change 'v1.at(0)' to L"one", it will work again
Heeeeeelp :( Why doesn't it work?
=================================================
Yeeeeeeeah now it works! :) Easy fix:
wstring zr = v1.at(0);
int z = m1[zr];
Double happy face ) Thanks to everybody for the help bro-s :)