cout: Clears the buffer and resets any error flags that may be set : cout sync clear « Console « C++






cout: Clears the buffer and resets any error flags that may be set

cout: Clears the buffer and resets any error flags that may be set

#include <iostream>    
#include <iomanip>     
#include <string>
using namespace std;
int main()
{
   string label;
   double price;
   cout << "Please enter an label: ";
   
   cin >> setw(16);        // cin.width(16);
   cin >> label;
   cin.sync();
   cin.clear();
   cout << "\nEnter the price: ";
   cin >> price;           

   
   cout << fixed << setprecision(2)   // Controlling output:
        << endl  << "Article:"
        << endl  << "Label:  " << label
        << endl  << "Price:  " << price << endl;

   return 0;
} 

           
       








Related examples in the same category

1.cout unset: clear flagcout unset: clear flag