[英]c2664 cannot convert parameter 2 from 'std::string' to 'const void *'
This is where I call the function.. 这是我调用该函数的地方。
memcpy(dataHashResult,sha1.operator()(dataBuffer,16),16);
I changed 我变了
/// compute SHA1 of a memory block ///计算内存块的SHA1
std::string operator()(const void* data, size_t numBytes);
to 至
std::string operator()(BYTE* data, size_t numBytes);
the types of buffers are.. 缓冲区的类型是..
unsigned char dataBuffer[64];
unsigned char dataHashResult[64];
Any help would be appreciated ..I'm new to C++.. Thanks. 任何帮助将不胜感激..我是C ++的新手。.谢谢。
try this: 尝试这个:
memcpy(dataHashResult,sha1.operator()(dataBuffer,16).c_str(),16);
The problem is that memcpy
needs a pointer to copy from. 问题是
memcpy
需要一个指针来复制。 Your original code gives it a std::string
object . 您的原始代码为其提供了一个
std::string
对象 。 Luckily, std::string
has a c_str()
function that returns the "C-style" string, ie a const char*
. 幸运的是,
std::string
具有一个c_str()
函数,该函数返回“ C样式”字符串,即const char*
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.