c++ - invalid conversion from `void*' to `char*' when using malloc? -


i'm having trouble code below error on line 5:

error: invalid conversion void* char*

i'm using g++ codeblocks , tried compile file cpp file. matter?

#include <openssl/crypto.h> int main() {     char *foo = malloc(1);     if (!foo) {         printf("malloc()");         exit(1);     }     openssl_cleanse(foo, 1);     printf("cleaned 1 byte\n");     openssl_cleanse(foo, 0);     printf("cleaned 0 bytes\n"); } 

in c++, need cast return of malloc()

char *foo = (char*)malloc(1); 

Comments

Popular posts from this blog

linux - Mailx and Gmail nss config dir -

c# - Is it possible to remove an existing registration from Autofac container builder? -

php - Mysql PK and FK char(36) vs int(10) -