C++中设置填充字符的错误,帮忙指导下.

来源:百度知道 编辑:UC知道 时间:2024/07/07 01:31:32
#include<iostream>
#include<iomanip>
using namespace std;
void main()
{
cout<<setfill('*')
<<setw(2)<<21<<endl;
<<setw(3)<<21<<endl;
<<setw(4)<<21<<endl;
cout<<setfill('');
}

--------------------Configuration: Cpp1 - Win32 Debug--------------------
Compiling...
Cpp1.cpp
E:\新建文件夹\Cpp1.cpp(8) : error C2143: syntax error : missing ';' before '<<'
E:\新建文件夹\Cpp1.cpp(9) : error C2143: syntax error : missing ';' before '<<'
E:\新建文件夹\Cpp1.cpp(10) : error C2137: empty character constant
E:\新建文件夹\Cpp1.cpp(10) : error C2679: binary '<<' : no operator defined which takes a right-hand operand of type 'struct std::_Fillobj<int>' (or there is no acceptable conversion)
Error executing cl.exe.

C

#include<iostream>
#include<iomanip>
using namespace std;
int main()
{
cout<<setfill('*')
<<setw(2)<<21<<endl;
cout<<setw(3)<<21<<endl;
cout<<setw(4)<<21<<endl;
cout<<"setfill('')"<<endl;
return 0;
}
建议你还是好好看看书啊!