Garbage when converting character to string using concatenation
I am converting a character to a string by concatenating it with an empty string (""). But it results in undefined behaviour or garbage characters in the resultant string. Why so?
char c = 'a';
string s = ""+c;
cout<<s<<" "<<s.size()<<"\n";
Aucun commentaire:
Enregistrer un commentaire