CHAPTER2-18.cpp
上传用户:fjc899
上传日期:2007-07-03
资源大小:187k
文件大小:1k
- //文件名:CHAPTER2-18.cpp
- #include <iostream>
- #include <string>
- using namespace std;
- void main()
- {
- string TestString = "1111122222333334444455555";
- //采用length()返回字符串长度
- cout << TestString << "n size: " << TestString.length() << endl;
- TestString.resize(5);
- //采用size()返回字符串长度
- cout << TestString << "n size: " << TestString.size() << endl;
- TestString.resize(10);
- cout << TestString << "n size: " << TestString.size() << endl;
- TestString.resize(15,'6');
- cout << TestString << "n size: " << TestString.size() << endl;
- }