[英]Left, right, and setw together for output problem
How can I make this: cout << right << setw(8) << showTime + " PM" << setw(13) << right << name << endl;
我怎样才能做到这一点:
cout << right << setw(8) << showTime + " PM" << setw(13) << right << name << endl;
Print like this: _8:00 PM_____________Mark Finch
像这样打印:
_8:00 PM_____________Mark Finch
So it's like this in a column:所以在一列中是这样的:
_8:00 PM_____________Mark Finch
_9:00 PM_____________Mark Bob
11:00 PM_____________Mars Bobinas
I'm wrong, but I just don't understand it please help...我错了,但我只是不明白,请帮助...
Looks like you want to print 13 spaces followed by the name:看起来您想打印 13 个空格,后跟名称:
cout << right << setw(8) << showTime + " PM" << setw(13) << " " << setw(1) << name << endl;
Note that you need to reset width back to 1 to avoid padding inside the name.请注意,您需要将宽度重置为 1 以避免名称内的填充。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.