📜  C++中的ios操纵器internal()函数

📅  最后修改于: 2021-05-30 12:23:34             🧑  作者: Mango

C++中的流操纵器internal()方法用于为指定的str流设置Adjustfield格式标志。该标志将adjustfield设置为internal。这意味着将通过在指定的内部点插入填充字符将输出中的数字填充为字段宽度。

句法:

ios_base& internal (ios_base& str)

参数:此方法接受str作为参数,这是影响格式标志的流。

返回值:该方法返回设置了内部格式标志的str。

范例1:

// C++ code to demonstrate
// the working of internal() function
  
#include 
  
using namespace std;
  
int main()
{
  
    // Initializing the integer
    double x = -1.23;
  
    cout.precision(5);
  
    // Using internal()
    cout << "internal flag: ";
  
    cout.width(12);
    cout << internal << x << endl;
  
    return 0;
}
输出:
internal flag: -       1.23

范例2:

// C++ code to demonstrate
// the working of internal() function
  
#include 
  
using namespace std;
  
int main()
{
  
    // Initializing the integer
    double x = -1.23;
  
    cout.precision(5);
  
    // Using internal()
    cout << "internal flag: ";
  
    cout.width(12);
    cout << internal << x << endl;
  
    return 0;
}
输出:
internal flag: -       1.23

参考: http : //www.cplusplus.com/reference/ios/internal/

要从最佳影片策划和实践问题去学习,检查了C++基础课程为基础,以先进的C++和C++ STL课程基础加上STL。要完成从学习语言到DS Algo等的更多准备工作,请参阅“完整面试准备课程”