Home:ALL Converter>Cannot convert const char to char

Cannot convert const char to char

Ask Time:2015-12-23T03:16:13         Author:Pietro Ariano

Json Formatter

char messaggiou[100];    
char *name2;
string encoded;

name2 = (char*)malloc(encoded.length() + 1); 
strcpy(name2, messaggiou);                                     
strcpy(encoded.c_str(), name2);           
const char* hex_str = name2;

I get an error with this code (simplified), with vs2015 in C ++.

error C2664: `'char *strcpy(char *,const char *)': cannot convert argument 1 from 'const char *' to 'char *'

P.s In messaggiou there is an encrypted string in hex

Author:Pietro Ariano,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/34422924/cannot-convert-const-char-to-char
yy