Ne.app NeANT
The Ne.app NeANT User module of the NeANT distribution.
moneyput.cpp
Go to the documentation of this file.
1
29#include <locale> // for locale, money_put, use_facet
30#include <iostream> // for cout, endl
31#include <iterator> // for ostreambuf_iterator
32#include <string> // for string
33
34#include <examples.h>
35
36
37int main ()
38{
39 typedef std::ostreambuf_iterator<char, std::char_traits<char> > Iter;
40
41 const std::string buffer ("10002");
42 const long double ldval = 10002;
43
44 // Construct a ostreambuf_iterator on cout
45 Iter begin (std::cout);
46
47 const std::locale loc;
48
49 // Get a money put facet
50 const std::money_put<char, Iter> &mp =
51 std::use_facet<std::money_put<char, Iter> >(loc);
52
53 // Put out the string representation of the monetary value
54 std::cout << buffer << " --> ";
55 mp.put (begin, false, std::cout, ' ', buffer);
56
57 // Put out the long double representation of the monetary value
58 std::cout << std::endl << ldval << " --> ";
59 mp.put (begin, false, std::cout, ' ', ldval);
60
61 std::cout << std::endl;
62
63 return 0;
64}
#define loc
Definition 17.names.cpp:492
#define buffer
Definition 17.names.cpp:453
std::ostream_iterator< int, char, std::char_traits< char > > Iter
Definition alg7.cpp:64
int main()
Definition moneyput.cpp:37