C++ c++;如何用多个字符填充空白宽度?

C++ c++;如何用多个字符填充空白宽度?,c++,C++,考虑以下代码: cout.width(5); cout.fill('x'); cout << 10 << endl; cout.width(5); cout.fill('x'); 不能像这样: string bank_of_characters = "xyzabcdefg..."; for(int i = 0; i < customLength; ++i) cout << bank_of_characters[i]; cout <<

考虑以下代码:

cout.width(5);
cout.fill('x');
cout << 10 << endl;
cout.width(5);
cout.fill('x');
不能像这样:

string bank_of_characters = "xyzabcdefg...";
for(int i = 0; i < customLength; ++i)
    cout << bank_of_characters[i];
cout << 10 << endl;
string bank\u of_characters=“xyzabcdefg…”;
对于(int i=0;i有几种方法。。。最好的一个取决于你需要什么,因为你总是可以做你自己的机械手,它可以做你想要的。但是在标准库中没有这样的功能。@StoryTeller只是用这种方式打印,比用像Joachim说的自定义操纵器打印要好。@StoryTeller如何做自定义操纵器?如何计算
customLength
?@Jarod42只需使用cout.width()-2是要打印的位数