i18n/loc1.cpp

The following code example is taken from the book
The C++ Standard Library - A Tutorial and Reference
by Nicolai M. Josuttis, Addison-Wesley, 1999
© Copyright Nicolai M. Josuttis 1999


#include <iostream>
#include <locale>
using namespace std;

int main()
{
    // use classic C locale to read data from standard input
    cin.imbue(locale::classic());

    // use a German locale to write data to standard ouput
    cout.imbue(locale("de_DE"));

    // read and output floating-point values in a loop
    double value;
    while (cin >> value) {
        cout << value << endl;
    }
}