Bonjour,
Question simple mais sans réponse pour moi encore :
Comment convertir un Char* en string...?
Merci.
Bonjour,
Question simple mais sans réponse pour moi encore :
Comment convertir un Char* en string...?
Merci.
Si je ne dis pas de betise quand tu fais:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8 // Ton char * char * s = "coucou"; // Ton string string s2; // Tu assigne ton char * a ton string s2 = s; // Tu affiche ça marche cout << s2 << endl;
std::string::string(const char*) et std::string::operator=(const char*) copient la chaîne C fournie (terminée par le caractère nul).
Juste un truc, si tu convertis depuis un char* et non pas un const char*, oublie pas de désalouer après![]()
Partager