CHAPTER2-24.cpp
上传用户:fjc899
上传日期:2007-07-03
资源大小:187k
文件大小:1k
- //文件名:CHAPTER2-24.cpp
- #include<string>
- #include <iostream>
- using namespace std;
- int main()
- {
- string test;
- while(test.empty() || test.size() <= 5)
- {
- cout << "Type a string between 5 and 100 characters long. "
- << endl;
- cin >> test;
- }
- cout << "Changing the third character from " << test[2] << " to * " << endl;
- test[2] = '*';
- cout << "now its: " << test << endl << endl;
- cout << "Identifying the middle: ";
- test.insert(test.size() / 2, "(the middle is here!)");
- cout << test << endl << endl;
- cout << "I didn't like the word 'middle',so instead,I'll say:"<< endl;
- test.replace(test.find("middle",0), 6, "center");
- cout << test << endl;
- return 0;
- }