C++中iomaip庫的resetiosflags()方法用於重置指定為此方法參數的ios庫格式標誌。
用法:
resetiosflags (ios_base::format_flag)
參數:此方法接受format_flag作為參數,這是要通過此方法重置的ios庫格式標誌。
返回值:此方法不返回任何內容。它僅充當流操縱器。
示例1:
// 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;
}
輸出:
Before reset:
0x32
Resetting showbase flag using resetiosflags:
32
示例2:
// 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;
}
輸出:
Before reset:
0x32
Resetting showbase and uppercase flag using resetiosflags:
32
參考: http://www.cplusplus.com/reference/iomanip/resetiosflags/
相關用法
- C++ iomanip setfill()用法及代碼示例
- C++ iomanip setw()用法及代碼示例
- C++ iomanip setpricision()用法及代碼示例
- C++ iomanip setiosflags()用法及代碼示例
- C++ iomanip setbase()用法及代碼示例
- C++ ios bad()用法及代碼示例
- C++ ios eof()用法及代碼示例
- C++ wcsspn()用法及代碼示例
- C++ wcscmp()用法及代碼示例
- C++ norm()用法及代碼示例
- C++ fill()用法及代碼示例
- C++ wcscpy()用法及代碼示例
- C++ conj()用法及代碼示例
- C++ ios clear()用法及代碼示例
- C++ ios rdstate()用法及代碼示例
注:本文由純淨天空篩選整理自guptayashgupta53大神的英文原創作品 iomanip resetiosflags() function in C++ with Examples。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。