I'm study about c++ using lamda expression. I'm just tried change the code that already coded using for or while, then i have the question about lamda.
I'm just change the code using lamda or for_each (c++11). How to change?
Here is a code that want to chage.
std::string PointToString(void* p_pData)
{
char* p = (char*)p_pData;
short iLength = 0;
std::memcpy(&iLength, p, sizeof(short));
p += sizeof(short);
std::string sRet;
std::array<char, 3> szB;
sRet.append("0x");
for ( short i = 0; i < iLength; i++ )
{
sprintf(szB.data(), "%02X", (unsigned char)*(p++));
sRet.append(szB.data());
}
return sRet;
}
This code just convert a memory value to hex code. That function called like this.
char szB[15] = {0x0b, 0x00, 0x00, 0x00, 0xc7, 0xd1, 0xb1, 0xdb, 0xc0, 0xd4, 0xb4, 0xcf, 0xb4, 0xd9, 0x2e};
void* p = nullptr;
p = (void*)szB;
sRet = PointToString(p);
The Result may be 0x0B000000C7D1.....
I want to try lamda in PointToString function. How can I change that function?
Aucun commentaire:
Enregistrer un commentaire