std :: cout打印字符N次

shi*_*raz 34 c++ cout

如何在std::cout不循环的情况下使用N次打印字符?

有没有办法将文本光标移回以取消效果std::cout << std::endl;?即向上移动一条线(假设我们在std::cout << std::endl;做手术后从未打印过任何东西).

seh*_*ehe 62

 std::cout << std::string(100, '*') << std::endl;
Run Code Online (Sandbox Code Playgroud)

要移动一行,您必须求助于终端转义(假设它isatty()表示您正在运行一个).

  • 或者首先没有品尝EOL? (2认同)

Ben*_*ley 15

std::cout << std::setfill(the_char) << std::setw(100) << "";
Run Code Online (Sandbox Code Playgroud)

  • setfill和setw需要<iomanip>标头 (7认同)