Mega Code Archive

 
Categories / C++ Tutorial / Development
 

Create a copy of the users locale

#include <iostream> #include <locale> #include <string> using namespace std; int main( ) {    locale loc(""); // Create a copy of the user's locale    cout << "Locale name = " << loc.name( ) << endl;    cout.imbue(loc); // Tell cout to use the formatting of                     // the user's locale    cout << "pi in locale " << cout.getloc( ).name( ) << " is "         << 3.14 << endl; } Locale name = C pi in locale C is 3.14