⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 6_72.cpp

📁 10个比较经典的C++程序。初学者就先多学习学习别人吧。
💻 CPP
字号:
#include <iostream>
#include <string>
using namespace std;
void DispInfo( const string & );
int main()
{  string str; cout << "Statistics before input:\n" << boolalpha; DispInfo( str );
   cout << "\nEnter a string: ";   cin >> str; 
   cout << "The string entered was: " << str;
   cout << "\nStatistics after input:\n";  DispInfo( str ); 
   str.resize( str.length() + 10 ); // 向str 中添加10 个元素
   cout << "\nStats after resizing by (length + 10):\n";   DispInfo( str );
   return 0;
} 
//输出字符串的特性
void DispInfo( const string &stringRef )
{  cout << "capacity: " 	<< stringRef.capacity() 
        << "\tmax size: " 	<< stringRef.max_size()
        << "\nsize: " 		<< stringRef.size() 
        << "\tlength: " 	<< stringRef.length()
        << "\tempty: " 		<< stringRef.empty();
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -