#include <iostream>
#include <string>
using namespace std;
int main()
{
cout << "Please enter your name: ";
string name;
cin >> name;
const string greeting = "Hello, " + name + "!";
const string spaces(greeting.size(), ' ');
const string second = "*" + spaces + "*";
const string first(second.size(), '*');
cout << endl;
cout << first << endl;
cout << second << endl;
cout << "*" << greeting << "*" << endl;
cout << second << endl;
cout << first << endl;
cout <<"试一试"<<first+greeting+second<<endl;
return 0;
}
eg:std::str(10,*);//-->str=十个*
s+t直接就是两个字符串无缝衔接(不过好像有限制?
x op=y == x=xopy(op为算术运算符或者移位符)
size_t是无符号整数类型(确保在不同平台上对内存大小的表示方式是一致的,从而提高了代码的可移植性)
#include <algorithm>
#include <iostream>
#include <string>
#include <ios>
#include <iomanip>
#include <vector>
using namespace st