chapter2-18.cpp
来自「C++STL程序员开发指南」· C++ 代码 · 共 18 行
CPP
18 行
//文件名: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;
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?