io/loc1.cpp

The following code example is taken from the book
Object-Oriented Programming in C++
by Nicolai M. Josuttis, Wiley, 2002
© Copyright Nicolai M. Josuttis 2002


#include <iostream>
#include <locale>

int main()
{
    // use the classic language environment in order to
    // read from the standard input
    std::cin.imbue(std::locale::classic());

    // use a German language environment in order to write data
    std::cout.imbue(std::locale("de_DE"));

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