Mega Code Archive

 
Categories / C++ Tutorial / Data Types
 

Show decimal point field when displaying double and set filler

#include <iostream> #include <iomanip> using namespace std; int main(int argc, char** argv) {   double dbl = 1.452;   double dbl2 = 5;   cout << "This should be 5: " << setw(2) << noshowpoint << dbl2 << endl;   cout << "This should be @@1.452: " << setw(7) << setfill('@') << dbl << endl; }