get_money in C++
The get_money function in C++ is used to parse a monetary value from the input stream.
Syntax of get_money
get_money(moneyT& mon, bool intl = false);
Here,
- mon: represents the object where the monetary value will be stored
- intl: Boolean value which is true of international representation and false otherwise.
Example of get_money
C++
// C++ program to illustrate the use of get_money functio #include <iomanip> #include <ios> #include <iostream> using namespace std; // driver code int main() { long double price; cout << "Enter the price: " ; // getting price using get_money function cin >> get_money(price); if (cin.fail()) { cout << "Sorry! We had an error reading the price" << endl; } else { cout << "The price is: " << price << endl; } return 0; } |
Output
Enter the price: 22
The price is: 22
< iomanip > Header in C++
In C++, the <iomanip> header file defines the manipulator functions that are used to manipulate the format of the input and output of our program. It is a part of the input/output library in C++. In this article, we will discuss the functions and facilities provided in the <iomanip> header file in C++ with examples.