#include <istream>
#include <ostream>
#include <iostream> /// cout
#include <sstream> /// istringstream
#include <locale>
#include <string>
using namespace std;
/// Copy a pair of values from an istream to an ostream.
void copy(istream& is, ostream& os)
{
float area;
double volume;
while (is >> area >> volume)
os << area << ' '
<< volume << '\n';
os << endl;
}
void test(istream& fin, ostream& fout,
istream& fin2, ostream& fout2)
{
fin.imbue(locale {"en_US.UTF-8"}); /// American English
fout.imbue(locale {"fr_FR.UTF-8"}); /// French
/// read American English, write French
copy(fin, fout);
/// ...
fin2.imbue(locale {"fr_FR.UTF-8"}); /// French
fout2.imbue(locale {"en_US.UTF-8"}); /// American English
/// read French, write American English
copy(fin2, fout2);
}
int main()
{
/// American English
string AmerEng {"100.3 1000.3 34.55 345.45 968.83 9688.321"};
istringstream issAmerEng {AmerEng};
/// French
string Frnch {"100,3 1000,3 34,55 345,45 968,83 9688,321"};
istringstream issFrnch {Frnch};
test(issAmerEng, cout,
issFrnch, cout);
}
I2luY2x1ZGUgPGlzdHJlYW0+CiNpbmNsdWRlIDxvc3RyZWFtPgojaW5jbHVkZSA8aW9zdHJlYW0+CQkvLy8gY291dAojaW5jbHVkZSA8c3N0cmVhbT4JCS8vLyBpc3RyaW5nc3RyZWFtCiNpbmNsdWRlIDxsb2NhbGU+CiNpbmNsdWRlIDxzdHJpbmc+Cgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKCi8vLyBDb3B5IGEgcGFpciBvZiB2YWx1ZXMgZnJvbSBhbiBpc3RyZWFtIHRvIGFuIG9zdHJlYW0uCnZvaWQgY29weShpc3RyZWFtJiBpcywgb3N0cmVhbSYgb3MpCnsKICAgIGZsb2F0IGFyZWE7CiAgICBkb3VibGUgdm9sdW1lOwoKICAgIHdoaWxlIChpcyA+PiBhcmVhID4+IHZvbHVtZSkKICAgICAgICBvcyA8PCBhcmVhIDw8ICcgJwogICAgICAgICAgIDw8IHZvbHVtZSA8PCAnXG4nOwoKICAgIG9zIDw8IGVuZGw7Cn0KCgp2b2lkIHRlc3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