I try to include unsigned char variable into std::string.it throws compiletime error.
unsigned char* SrvName;
std::string m_sSMTPSrvName;
//srvName contains "207.45.255.45"
m_sSMTPSrvName.insert(0, SrvName);
Error
error C2664: 'std::basic_string<_Elem,_Traits,_Ax> &std::basic_string<_Elem,_Traits,_Ax>::insert(unsigned int,const std::basic_string<_Elem,_Traits,_Ax> &)' : cannot convert parameter 2 from 'const unsigned char *' to 'const std::basic_string<_Elem,_Traits,_Ax> &'
Why do you use
unsigned char*in the first place?Anyway, if
SrvNameis null-terminated, you can do:Or if you know
SrvName‘s length, you can do:EDIT:
After reading your new comment, looks like what you actually want is to convert the numbers in the array to a string that represents an IP address. You can do it this way: