创建详解
#include
#include
#include
#include
#include
usingnamespace std;
int main()
{
//1. 字符串的创建
cout<<"第一:字符串的创建!\n\n";
string a(4,'a');
cout<<"1.以 a 为原字符 4单位大小\n\n";
cout<<"string a(4,'a');\ncout<;
cout<<a<<endl<<endl;
cout<<"2.任意大小的字符串\n\n";
cout<<"string b(\"bbbbbb\");\ncout<;
string b("bbbbbb");
cout<<b<<endl<<endl;
cout<<"3.把某一字符串的某一部分\n(0位置开始4个长度)给c\n\n";
cout<<"string c(a,0,4) ;\ncout<;
string c(a,0,4);
cout<<c<<endl<<endl;
cout<<"4. 10长度原长度不足补*;\n\n";
cout<<"c.resize(10,'*');\ncout<;
c.resize(10,'*');
cout<<c<<endl<<endl;
system("pause");
system("cls");
return0;
}