hash_map <char *,CSimplificada,hash_compare <char*, eqstr> >::iterator itBusca;
CSimplificada sS1;
for(int i=0;i<nRecords;i++) { // nRecords is the number of records where a have the data
itBusca = hashMapS1.find(sKey); // sKey is declared as: char sKey[256]; and fill which data of the i-record
if(itBusca == itS1End) { // not found, add the new key and data
sS1.nTipo = S1; // S1 is: #define S1 0
sS1.vnPosInFile.push_back(i);
hashMapS1[sKey] = sS1;
} else { // encontrado
itBusca->second.vnPosInFile.push_back(i);
}
}
the term: if(itBusca == itS1End) allways evaluated as true but I can find records with the same key.
Is there a specific reason why you use char[256] instead of string?
Did you make sure the char* used as hash_map key never goes out of scope and remains constant?
Each time you change the sKey string to something different it also affects the elemt already stored in your hash_map, because its key points to sKey. You always refer to the same memory address, that´s why find always returns a valid iterator.
the term: if(itBusca == itS1End) allways evaluated as true but I can find records with the same key.
What is happening now
I haven't worked with Studio 2003 for a long time, but I hope that hash_map implementation in Studio 2005 is the same. The problem is that Microsoft hash_map requires keys to be less than comparable, so instead of eqstr you need less_str (or greater_str, whatever you like). For example
* The Best Reasons to Target Windows 8
Learn some of the best reasons why you should seriously consider bringing your Android mobile development expertise to bear on the Windows 8 platform.