stl string 函数_使用C ++ STL中的string :: append()函数将文本追加到字符串
stl string 函數(shù)
append() is a library function of <string> header, it is used to append the extra characters/text in the string.
append()是<string>標頭的庫函數(shù),用于在字符串中附加多余的字符/文本。
Syntax:
句法:
string& append(const string& substr);Here,
這里,
string& is the reference to the string in which we are adding the extra characters.
string&是對要在其中添加額外字符的字符串的引用。
substr is the extra set of character/sub-string to be appended.
substr是要附加的字符/子字符串的額外集合。
There are some other variations (function overloading) of the function that are going to be used in the program.
程序中還將使用該函數(shù)的其他一些變體(函數(shù)重載)。
Program:
程序:
#include <iostream> #include <string> using namespace std;int main () {string str = "Hello";string str2 = " ## ";string str3 = "www.google.com";cout<<str<<endl;//append text at the end str.append (" world");cout<<str<<endl;//append 'str2'str.append (str2) ;cout<<str<<endl;//append space str.append (" ");//append 'google' from str3str.append (str3.begin () +4, str3.begin () +10) ;cout<<str<<endl;return 0; }Output
輸出量
HelloHello worldHello world ## Hello world ## google翻譯自: https://www.includehelp.com/stl/appending-text-to-the-string-using-string-append-function.aspx
stl string 函數(shù)
總結
以上是生活随笔為你收集整理的stl string 函数_使用C ++ STL中的string :: append()函数将文本追加到字符串的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 工作几年了,原来我只用了数据校验的皮毛
- 下一篇: css 隐藏元素 显示元素_使用CSS打