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

📄 413.cpp

📁 C++实训教程
💻 CPP
字号:
//413.cpp   使用string类的接口
#include <iostream.H>
#include <cstring.H>
main(void)
{
   string s1("abcdefghijk"), s2("1234567890"), s3,s4,s5;           // copy

   s3=s1+s2;
   cout << s3 <<endl;
   cout << "s3 length=" << s3.length()<< endl;

   size_t pos;
   pos=s3.find(s2);
   cout << "The find Position is " << pos << endl;

   s4=s3;
   if (s4==s3) cout << " s4==s3 is true\n";

   s4.prepend("====");
   cout << s4 <<endl;

   s1.append(s2,3); //append from s2[3]
   cout << s1 <<endl;
	return(0);
}
/*
abcdefghijk1234567890
s3 length=21
The find Position is 11
 s4==s3 is true
====abcdefghijk1234567890
abcdefghijk4567890

*/

⌨️ 快捷键说明

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