can any body tell me how to conver const char* to char*?
get_error_from_header(void *ptr, size_t size, size_t nmemb, void *data) {
ErrorMsg *error = (ErrorMsg *)data;
char* err = strstr((const char *)ptr,"550");
//error cannot convert const char** to char*
if(err) {
strncpy(error->data,(char*)ptr,LENGTH_ERROR_MESSAGE-1);
error->data[LENGTH_ERROR_MESSAGE-1] = '\0';
error->ret = true;
}
return size*nmemb;
}
You don’t appear to use
errin the rest of that function, so why bother creating it?If you do need it, will you really need to modify whatever it points to? If not, then declare it as
constalso:Finally, as casts are such nasty things, it is best to use a specific modern-style cast for the operation you want to perform. In this case: