使用std流打印16进制字符串示例

来源:互联网 发布:阿里云服务器价格计算 编辑:程序博客网 时间:2024/06/03 15:44
//depend on  <sstream> and <iomanip> include.//std::string _strLastErrorstd::ostringstream ostr;fingerprint = libssh2_hostkey_hash(_session, LIBSSH2_HOSTKEY_HASH_SHA1);ostr << "Fingerprint: ";  for (int i = 0; i < 20; i++) {  unsigned char c = fingerprint[i];  int nT = c;  ostr << std::hex << std::setw(2) << std::setfill('0') << nT;  }  _strLastError = ostr.str();



编译libssh要注意下面两个问题:

[1] 要依赖的头文件路径不是"D:\sdk\openssl-0.9.8o\include"而是“D:\sdk\openssl-0.9.8o\inc32”
[2]在用Visual Studio打开工程前,可以修改“D:\sdk\libssh2-1.4.3\win32\config.mk”中OpenSSL和Zlib路径的配置。

0 0
原创粉丝点击