I've tried to convert an integer to a hex null-terminated (or "C-style") string but I cannot use it with printf or my custom log function. It only works if I convert it to an std::string then use .c_str() when passing it as a parameter, which produces ugly, hard-to-understand code.
It's important to know that using std::string and appending to it with "str +=" does work.
const char* IntToHexString(int nDecimalNumber) {
    int nTemp = 0;
    char szHex[128] = { 0 };
    char hex[] = { '0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F' };
    while (nDecimalNumber > 0) {
        nTemp = nDecimalNumber % 16;
        sprintf(szHex, "%s%s", hex[nTemp], szHex);
        nDecimalNumber = nDecimalNumber / 16;
    }
    sprintf(szHex, "0x%s", szHex);
    return szHex;
}
I've tried to use Visual Studio Debugger but it doesn't show any error messages, because crashes somewhere in a DLL that has no symbols loaded
 
     
     
    