C++语言之“标准字符串 std::string”

#include<iostream>
#include<string>

using namespace std;

int main()
{
string greetString("Hello std::string!");
cout << greetString << endl;

cout << "Enter a line of text:" << endl;
string firstLine;
getline(cin,firstLine);

cout << "enter another: " << endl;
string secondLine;
getline(cin,secondLine);

cout << "Result of concatenation:" << endl;
string concatString = firstLine + secondLine;
cout << concatString << endl;

cout << "copy of concatenated string:" << endl;
string aCopy;
aCopy = concatString;
cout << aCopy << endl;

return 0;

}

猜你喜欢

转载自blog.csdn.net/m0_37811192/article/details/81044569