【发布时间】:2014-03-15 10:08:57
【问题描述】:
void listUser(student user[], int size, int const track)
{
int list;
cout<< "\n\tName|||Age|||Gender|||Course|||Year|||Section|||Student No.\n";
for (list=0; list<track; list++)
{
cout<< "\n\n" << user[list].firstname <<" " << user[list].lastname <<"\t\t" << user[list].age <<"\t" << user[list].gender << "\t" << user[list].course << "\t" << user[list].year << "\t" << user[list].section << " " << user[list].studno <<"\n";
}
return;
}
所以,这是我的代码的一部分,它在命令行窗口上显示用户列表。我的问题是,如何在不使用制表符的情况下格式化输出/显示?
当列表中的用户具有长名称或短名称时,它看起来很难看并且有些不美观。谢谢。
【问题讨论】:
-
检查
std::setw()io 操纵器。std::setfill()也可能有用。