Open In App
Related Articles

iomanip resetiosflags() function in C++ with Examples

Improve Article
Improve
Save Article
Save
Like Article
Like

The resetiosflags() method of iomanip library in C++ is used to reset the ios library format flags specified as the parameter to this method.
Syntax: 
 

resetiosflags (ios_base::format_flag)

Parameters: This method accepts format_flag as a parameter which is the ios library format flag to be reset by this method.
Return Value: This method does not returns anything. It only acts as stream manipulators.
Example 1:
 

CPP




// C++ code to demonstrate
// the working of resetiosflags() function
 
#include <iomanip>
#include <ios>
#include <iostream>
 
using namespace std;
 
int main()
{
 
    // Initializing the integer
    int num = 50;
 
    cout << "Before reset: \n"
         << hex
         << setiosflags(ios::showbase)
         << num << endl;
 
    // Using resetiosflags()
    cout << "Resetting showbase flag"
         << " using resetiosflags: \n"
         << resetiosflags(ios::showbase)
         << num << endl;
 
    return 0;
}


Output: 

Before reset: 
0x32
Resetting showbase flag using resetiosflags: 
32

 

Example 2:
 

CPP




// C++ code to demonstrate
// the working of resetiosflags() function
 
#include <iomanip>
#include <ios>
#include <iostream>
 
using namespace std;
 
int main()
{
 
    // Initializing the integer
    int num = 50;
 
    cout << "Before reset: \n"
         << hex
         << setiosflags(ios::showbase)
         << num << endl;
 
    // Using resetiosflags()
    cout << "Resetting showbase and uppercase"
         << " flag using resetiosflags: \n"
         << resetiosflags(ios::showbase)
         << num << endl;
 
    return 0;
}


Output: 

Before reset: 
0x32
Resetting showbase and uppercase flag using resetiosflags: 
32

 

Reference: http://www.cplusplus.com/reference/iomanip/resetiosflags/
 


Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out - check it out now!

Last Updated : 12 Jun, 2021
Like Article
Save Article
Similar Reads