<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                企業??AI智能體構建引擎,智能編排和調試,一鍵部署,支持知識庫和私有化部署方案 廣告
                # C `strcat()`函數 > 原文: [https://beginnersbook.com/2017/11/c-strcat-function-with-example/](https://beginnersbook.com/2017/11/c-strcat-function-with-example/) `strcat()`函數用于字符串連接。它在另一個指定字符串的末尾連接指定的字符串。在本教程中,我們將看到帶示例的 `strcat()`函數。 ## C `strcat()`聲明 ```c char *strcat(char *str1, const char *str2) ``` 此函數將兩個指針作為參數,并在連接后返回指向目標字符串的指針。 `str1` - 指向目標字符串的指針。 `str2` - 指向附加到目標字符串的源字符串的指針。 ## 示例:C `strcat()`函數 ```c #include <stdio.h> #include <string.h> int main () { char str1[50], str2[50]; //destination string strcpy(str1, "This is my initial string"); //source string strcpy(str2, ", add this"); //concatenating the string str2 to the string str1 strcat(str1, str2); //displaying destination string printf("String after concatenation: %s", str1); return(0); } ``` 輸出: ```c String after concatenation: This is my initial string, add this ``` 正如您所看到的,我們在字符串`str1`的末尾添加了字符串`str2`。我們將參數傳遞給函數`strcpy`的順序很重要,第一個參數指定輸出字符串,而第二個參數指定附加在輸出字符串末尾的另一個字符串。 正如文章開頭所討論的那樣,該函數返回指向目標字符串的指針。這意味著如果我們顯示此函數的返回值,那么它應該顯示目標字符串(在我們的示例中為字符串`str1`)。讓我們稍微修改我們的代碼來驗證這一點。 ```c #include <stdio.h> #include <string.h> int main () { char str1[50], str2[50]; //destination string strcpy(str1, "This is my initial string"); //source string strcpy(str2, ", add this"); //displaying destination string printf("String after concatenation: %s", strcat(str1, str2)); return(0); } ``` 輸出: ```c String after concatenation: This is my initial string, add this ```
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看