setw函数设置iostream流的输出域宽度,类似c函数中的printf("%20d",100);中的20,但是有点区别,在用复数测试setw函数时,没有感觉有什么作用,输出原本就是默认居左的,而宽度并没有影响下一个输出。测试后发现,setw仅仅影响其后面的一个输出流内容。
[code]#i nclude
#i nclude
using namespace std;
int main(int argc, char * argv[])
{
cout< cout< cout<<"four"< cout<<"five"< return 0;
}[/code] |