// [...] char* tmp = ca(caf); std::cout << tmp << std::endl; delete [] tmp; // [...]
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre question#include #include <sstream> #include <cstring> struct SetOEM { SetOEM(const char* s) : _oem(s) { } const char* _oem; }; inline SetOEM OEM(const char* s) { return SetOEM(s); } template <class charT, class traits> std::basic_ostream<charT, traits>& operator<<(std::basic_ostream<charT, traits>& out, SetOEM oem) { char* s; s = new char[strlen(oem._oem) + 1]; strcpy(s, oem._oem); //Remplace par CharToOem(oem, s); out << s; delete [] s; return out; } int main () { char caf[] = "Les caractères français doivent être convertis"; std::cout << std::endl << OEM("Démo de ca() n° 1 : ") << OEM(caf) << std::endl << OEM("Démo de ca() n° 2 : ") << OEM("Noëlle aperçut là-bas l'âne bâté") << std::endl << std::endl << std::endl << "Au revoir !" << std::endl << std::endl; //getchar(); return 0; }
#include #include <sstream> #include <cstring> struct SetOEM { SetOEM(const char* s) : _s(s) { } const char* _s; }; inline SetOEM OEM(const char* s) { return s; } std::ostream& operator<<(std::ostream& out, const SetOEM& oem) { char* s = new char[strlen(oem._s) + 1]; strcpy(s, oem._s); //CharToOem(oem._s, s); out << s; delete [] s; return out; } int main () { char caf[] = "Les caractères français doivent être convertis"; std::cout << std::endl << OEM("Démo de ca() n° 1 : ") << OEM(caf) << std::endl << OEM("Démo de ca() n° 2 : ") << OEM("Noëlle aperçut là-bas l'âne bâté") << std::endl << std::endl << std::endl << "Au revoir !" << std::endl << std::endl; //getchar(); return 0; }
#include #include <clocale> int main (int argc, char* argv[]) { setlocale( LC_CTYPE , "fra" ) ; std::cout << "Noëlle aperçut là-bas l'âne bâté"" << std::endl ; }