gpt4 book ai didi

c++ - 在ConsoleApplication2.exe中的0x00080000处引发异常:0xC0000005:执行访问位置0x00080000 Visual Studio的访问冲突

转载 作者:行者123 更新时间:2023-12-02 10:34:39 25 4
gpt4 key购买 nike

我已经查看过类似的主题,但无法解决此问题。

这是我的代码:

#include <iostream>
#include <sstream>
#include <string>
#include <iomanip>
#include <stdio.h>
#include <openssl/sha.h>

#define _CRT_SECURE_NO_WARNINGS

std::string sha256(const std::string str)
{
unsigned char hash[SHA256_DIGEST_LENGTH];
SHA256_CTX sha256;
SHA256_Init(&sha256); //HERE I AM RECEIVING ERROR
SHA256_Update(&sha256, str.c_str(), str.size());

SHA256_Final(hash, &sha256);

std::stringstream ss;
for (int i = 0; i < SHA256_DIGEST_LENGTH; i++)
{
ss << std::hex << std::setw(2) << std::setfill('0') << (int)hash[i];
}

return ss.str();
}

void sha256_hash_string(unsigned char hash[SHA256_DIGEST_LENGTH], char outputBuffer[65])
{
int i = 0;

for (i = 0; i < SHA256_DIGEST_LENGTH; i++)
{
#pragma warning(suppress : 4996) sprintf(outputBuffer + (i * 2), "%02x", hash[i]);
}

outputBuffer[64] = 0;
}

int main()
{
// hash a string
std::cout << "SHA-256 hash of \"Sample String\" text:" << std::endl;
std::cout << sha256("Sample String") << std::endl << std::endl;

// hash a file

return 0;
}

我在它给我错误的行上评论:

Exception thrown at 0x00080000 in ConsoleApplication2.exe: 0xC0000005: Access violation executing location 0x00080000.



链接器配置:
linker>input

linker > general

C / C++配置:
C/C++.general

最佳答案

您的构建配置显示您正在32位模式下进行构建,即Debug Win-32,但要链接的库是64位。您需要将构建配置设置为64位,再次构建项目并运行。

此外,如果程序库不在系统路径中,则需要将所需的DLL复制到程序二进制文件所在的构建目录中,例如System32。如果您交付应用程序,请注意在打包系统配置中添加此步骤。

关于c++ - 在ConsoleApplication2.exe中的0x00080000处引发异常:0xC0000005:执行访问位置0x00080000 Visual Studio的访问冲突,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60924700/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com