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

📄 append.html

📁 从www.CppReference.com打包的C++参考手册
💻 HTML
字号:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head>  <meta name="generator" content=  "HTML Tidy for Linux/x86 (vers 1 September 2005), see www.w3.org">  <title>append</title>  <link href="../cppreference.css" rel="stylesheet" type="text/css"></head><body><table>  <tr>  <td>  <div class="body-content">  <div class="header-box">    <a href="../index.html">cppreference.com</a> &gt; <a href=    "index.html">C++ Strings</a> &gt; <a href="append.html">append</a>  </div>  <div class="name-format">    append  </div>  <div class="syntax-name-format">    Syntax:  </div>  <pre class="syntax-box">  #include &lt;string&gt;  string&amp; append( const string&amp; str );  string&amp; append( const char* str );  string&amp; append( const string&amp; str, <strong>size_type</strong> index, <strong>size_type</strong> len );  string&amp; append( const char* str, <strong>size_type</strong> num );  string&amp; append( <strong>size_type</strong> num, char ch );  string&amp; append( <a href="../iterators.html">input_iterator</a> start, <a href="../iterators.html">input_iterator</a> end );</pre>  <p>The append() function either:</p>  <ul>    <li>appends <em>str</em> on to the end of the current string,</li>    <li>appends a substring of <em>str</em> starting at <em>index</em>    that is <em>len</em> characters long on to the end of the current    string,</li>    <li>appends <em>num</em> characters of <em>str</em> on to the end    of the current string,</li>    <li>appends <em>num</em> repititions of <em>ch</em> on to the end    of the current string,</li>    <li>or appends the sequence denoted by <em>start</em> and    <em>end</em> on to the end of the current string.</li>  </ul>  <p>For example, the following code uses append() to add 10 copies of  the &#39;!&#39; character to a string:</p>  <pre class="example-code">   string str = &quot;Hello World&quot;;   str.append( 10, &#39;!&#39; );   cout &lt;&lt; str &lt;&lt; endl;             </pre>  <p>That code displays:</p>  <pre class="example-code">   Hello World!!!!!!!!!!                </pre>  <p>In the next example, append() is used to concatenate a substring  of one string onto another string:</p>  <pre class="example-code"> string str1 = &quot;Eventually I stopped caring...&quot;; string str2 = &quot;but that was the &#39;80s so nobody noticed.&quot;; str1.append( str2, 25, 15 ); cout &lt;&lt; &quot;str1 is &quot; &lt;&lt; str1 &lt;&lt; endl; </pre>  <p>When run, the above code displays:</p>  <pre class="example-code"> str1 is Eventually I stopped caring...nobody noticed.          </pre>  </div>  </td>    </tr>  </table></body></html>

⌨️ 快捷键说明

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