當前位置: 首頁>>編程示例 >>用法及示例精選 >>正文


C++ iomanip resetiosflags()用法及代碼示例

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/



相關用法


注:本文由純淨天空篩選整理自guptayashgupta53大神的英文原創作品 iomanip resetiosflags() function in C++ with Examples。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。