相关疑难解决方法(0)

使用malloc时,从`void*'无效转换为`char*'?

我在第5行的错误中遇到了以下代码的问题:

错误:无效转换void*char*

我正在使用g ++和codeblocks,我试图将此文件编译为cpp文件.有关系吗?

#include <openssl/crypto.h>
int main()
{
    char *foo = malloc(1);
    if (!foo) {
        printf("malloc()");
        exit(1);
    }
    OPENSSL_cleanse(foo, 1);
    printf("cleaned one byte\n");
    OPENSSL_cleanse(foo, 0);
    printf("cleaned zero bytes\n");
}
Run Code Online (Sandbox Code Playgroud)

c++ malloc g++

55
推荐指数
4
解决办法
8万
查看次数

标签 统计

c++ ×1

g++ ×1

malloc ×1