C++语言开发示例:11. 字符串类型2
strtype2.cpp
#include <iostream>
#include <string>
int main()
{
using namespace std;
string s1 = "penguin";
string s2, s3;
cout << "You can assign one string object to another: s2 = s1\n";
s2 = s1;
cout << "s1: " << s1 << ", s2: " << s2 << endl;
cout << "You can assign a C-style string to a string object.\n";
cout << "s2 = \"buzzard\"\n";
s2 = "buzzard";
cout << "s2: " << s2 << endl;
cout << "You can concatenate strings: s3 = s1 + s2\n";
s3 = s1 + s2;
cout << "s3: " << s3 << endl;
cout << "You can append strings.\n";
s1 += s2;
cout << "s1 += s2 yields s1 = " << s1 << endl;
s2 += " for a day";
cout << "s2 += \" for a day\" yields s2 = " << s2 << endl;
} 最后更新于1年前
本文由人工编写,AI优化,转载请注明原文地址: C++语言开发示例:11. 字符串类型2
推荐阅读
IntelliJ IDEA常见问题解决方案大全:服务面板、Maven报错、启动故障处理
3472026-04-14
达梦数据库libgeos_c.dll加载失败解决方法:空间数据包安装指南
202026-04-14
GeoServer连接达梦数据库完整指南:空间数据配置与常见问题解决
302026-04-15
程序员常用技术大全:从编程语言到开发工具完整指南
4932025-10-19
VMware Workstation 17许可证密钥及免费激活方法详解
36442025-10-26
Windows系统PyTorch安装教程:CUDA 12.1环境配置与TorchText版本兼容性指南
24482025-10-08