stl 连接 字符串_在C ++ STL中使用+(加号)运算符连接两个字符串

stl 连接 字符串 字符串作为数据类型 (String as datatype)In C, we know string basically a character array terminated by \0. Thus to operate with the string we define character array. But in C++, standard library giv...
摘要由CSDN通过智能技术生成

stl 连接 字符串

字符串作为数据类型 (String as datatype)

In C, we know string basically a character array terminated by \0. Thus to operate with the string we define character array. But in C++, standard library gives us the facility to use string as a basic data type like integer.

在C语言中,我们知道字符串基本上是一个以\ 0结尾的字符数组。 因此,要对字符串进行操作,我们定义了字符数组。 但是在C ++中,标准库为我们提供了将字符串用作基本数据类型(如整数)的便利。

Example:

例:

    Like we define and declare,
    int i=5,j=7,k;
    Same way, we can do for a string like,
    string s1="Include", s2="Help";

    Now,
    k=i+j; // 12
    Same way we can concatenate our two string s1 & s2
    string s3=s1+s2;
    now s3 is &
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值