Convert Byte[64] to CSTRIng
-
Hi, Please have a look std::vector Names; ENUMLOGFONTEX *lpelfe; Names.push_back(lpelfe->elfFullName); the above lines gives an error like.... error C2440: 'initializing' : cannot convert from 'BYTE [64]' to 'ATL::CStringT<BaseType,StringTraits>'with[BaseType=char, StringTraits=StrTraitMFC_DLL<char>] ] and please try to help regarding the same...
-
Hi, Please have a look std::vector Names; ENUMLOGFONTEX *lpelfe; Names.push_back(lpelfe->elfFullName); the above lines gives an error like.... error C2440: 'initializing' : cannot convert from 'BYTE [64]' to 'ATL::CStringT<BaseType,StringTraits>'with[BaseType=char, StringTraits=StrTraitMFC_DLL<char>] ] and please try to help regarding the same...
What type of data do you want to push to std::vector? If you want CString, try
std::vector Names;
Names.push_back(new CString(lpelfe->elfFullName));or you do with BYTE[], try
std::vector Names;
BYTE* aName = new BYTE[sizeof(lpelfe->elfFullName)];
memcpy(aName, lpelfe->elfFullName, sizeof(lpelfe->elfFullName);
Names.push_back(aName);Do not forget delete elements after you dont need vector both above.
-
Hi, Please have a look std::vector Names; ENUMLOGFONTEX *lpelfe; Names.push_back(lpelfe->elfFullName); the above lines gives an error like.... error C2440: 'initializing' : cannot convert from 'BYTE [64]' to 'ATL::CStringT<BaseType,StringTraits>'with[BaseType=char, StringTraits=StrTraitMFC_DLL<char>] ] and please try to help regarding the same...
Your vector declaration cannot be seen in your posting. Is it declared
std::vector<CString>
?«_Superman_» I love work. It gives me something to do between weekends.
-
What type of data do you want to push to std::vector? If you want CString, try
std::vector Names;
Names.push_back(new CString(lpelfe->elfFullName));or you do with BYTE[], try
std::vector Names;
BYTE* aName = new BYTE[sizeof(lpelfe->elfFullName)];
memcpy(aName, lpelfe->elfFullName, sizeof(lpelfe->elfFullName);
Names.push_back(aName);Do not forget delete elements after you dont need vector both above.
-
What type of data do you want to push to std::vector? If you want CString, try
std::vector Names;
Names.push_back(new CString(lpelfe->elfFullName));or you do with BYTE[], try
std::vector Names;
BYTE* aName = new BYTE[sizeof(lpelfe->elfFullName)];
memcpy(aName, lpelfe->elfFullName, sizeof(lpelfe->elfFullName);
Names.push_back(aName);Do not forget delete elements after you dont need vector both above.
I think , first Option should work. Bcoz while creating CString from Byte , you should say new() to it..
It's not enough to be the best, when you have capability to be great...
-
Your vector declaration cannot be seen in your posting. Is it declared
std::vector<CString>
?«_Superman_» I love work. It gives me something to do between weekends.
-
Try a two step approach.
std::vector<CString> Names;
ENUMLOGFONTEX *lpelfe;
CString str = lpelfe->elfFullName;
Names.push_back(str);«_Superman_» I love work. It gives me something to do between weekends.
-
Hi, Please have a look std::vector Names; ENUMLOGFONTEX *lpelfe; Names.push_back(lpelfe->elfFullName); the above lines gives an error like.... error C2440: 'initializing' : cannot convert from 'BYTE [64]' to 'ATL::CStringT<BaseType,StringTraits>'with[BaseType=char, StringTraits=StrTraitMFC_DLL<char>] ] and please try to help regarding the same...
Can't you just use CString if you are already using MFC? Why do you have to use the std containers?!
It is a crappy thing, but it's life -^ Carlo Pallini