std::cout 打印字符 N 次
如何使用 std::cout 打印一个字符 N 次而不循环?
有没有办法将文本光标移回以消除 std::cout << 的效果std::endl;
?即向上移动一行(假设我们在执行 std::cout << std::endl; 操作后从未打印过任何内容)。
How can I print a character N number of times using std::cout
without looping?
Is there a way to move the text cursor back to nullify the effect of std::cout << std::endl;
? i.e. to move up a line (say we never printed anything after doing the std::cout << std::endl;
operation).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
![扫码二维码加入Web技术交流群](/public/img/jiaqun_03.jpg)
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
要向上移动一行,您必须求助于终端转义(假设
isatty()
表明您正在运行一个终端)。To move a line up, you have to resort to terminal escapes (assuming that
isatty()
indicates that you are running on one).使用 三元运算符(或者 if 语句,如果您引用的话)...类似...
Use the ternary operator (or an if statement if you refer) ... something like ...