dimanche 8 décembre 2019

cpp check complains dangerous use of c_str(). the value returned by c_str() is invalid after this call , how to solve this?

if(ini_getstr(getname("hello"))) //this is the getname function call

char* ini_getstr(char * key) { //some code }

char* getname(std::string name) //need to return char* 
{ 
   std::string ininame("name"); 
   ininame.append(":"+name); 
   return (*char)ininame.c_str();//cpp check complains dangerous use of c_str().
}

Aucun commentaire:

Enregistrer un commentaire