- //文件名:CHAPTER2-23.cpp
- #include <string>
- #include <iostream>
- #include <algorithm>
- using namespace std;
- int main()
- {
- string s(10u, ' '); // Create a string of ten blanks.
- const char* A = "this is a test";
- s += A;
- cout << "s = " << (s + 'n');
- cout << "As a null-terminated sequence: " << s.c_str() << endl;
- cout << "The sixteenth character is " << s[15] << endl;
- reverse(s.begin(), s.end());
- cout << s<<endl;
- return 0;
- }