Hi Guys,
I am facing an interesting situation and want to share with all. Definitely, if some one can help I shall be grateful!
#include "stdafx.h"
#include <map>
#define DEF_NAME1 "NAME1"
#define DEF_NAME2 "NAME2"
#define DEF_NAME3 "NAME3"
#define DEF_NAME4 "NAME4"
struct TInfo
{
const char * TName;
const char * TArray1[100];
const char * TArray2[100];
};
typedef std::map<const char*, TInfo*> TInfoMap;
typedef std::pair<const char*,TInfo*> TInfoPair;
static TInfoMap tinfomap;
TInfo TInfoArray[] =
{
{DEF_NAME1,{""}, {""}},
{DEF_NAME2,{""}, {""}},
{DEF_NAME3,{""}, {""}},
{DEF_NAME4,{""}, {""}}
};
TInfoMap* GetTInfoMap()
{
for (int i = 0; i < 3 ; i++ )
tinfomap.insert(TInfoPair(TInfoArray[i].TName,&TInfoArray[i]));
return &tinfomap;
}
int _tmain(int argc, _TCHAR* argv[])
{
char *name="NAME3";
TInfo* ptr = new TInfo();
TInfoMap* map1 = GetTInfoMap();
if ( map1->find(name) == map1->end() )
printf("Not found");
else
printf("Found!");
return 0;
}
I am on windows 2003 Server 64bit. I get output "Found!" when I compile/run this programe in Release mode and the output is "Not found" when I complile/run this programe in Debug mode.
Any idea?
Regards,
Azher