<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 `strcpy()`函數 > 原文: [https://beginnersbook.com/2017/11/c-strcpy-function/](https://beginnersbook.com/2017/11/c-strcpy-function/) **`strcpy()`函數**將一個字符串復制到另一個字符串。 ## C `strcpy()`函數聲明 ```c char *strcpy(char *str1, const char *str2) ``` `str1` - 這是復制其他字符串`str2`的值的目標字符串。函數的第一個參數。 `str2` - 這是源字符串,該字符串的值被復制到目標字符串。這是函數的第二個參數。 ## `strcpy()`的返回值 此函數返回指向目標字符串的指針,或者您可以說它返回目標字符串`str1`。 ## 示例:`strcpy()`函數 ```c #include <stdio.h> #include <string.h> int main () { char str1[20]; char str2[20]; //copying the string "Apple" to the str1 strcpy(str1, "Apple"); printf("String str1: %s\n", str1); //copying the string "Banana" to the str2 strcpy(str2, "Banana"); printf("String str2: %s\n", str2); //copying the value of str2 to the string str1 strcpy(str1, str2); printf("String str1: %s\n", str1); return 0; } ``` 輸出: ```c String str1: Apple String str2: Banana String str1: Banana ``` 正如我在帖子的開頭所提到的,這個函數返回指向目標字符串的指針,這意味著如果我們顯示函數的返回值,它應該在將源字符串復制到目標字符串后顯示目標字符串的值。讓我們舉一個例子來理解這一點。 ```c #include <stdio.h> #include <string.h> int main () { char str[20]; /* copying the string "Apple" to the str and * displaying the return value of strcpy() */ printf("Return value of function: %s\n", strcpy(str, "Apple")); printf("String str1: %s\n", str); return 0; } ``` 輸出: ```c Return value of function: Apple String str1: Apple ``` #### 相關文章: 1. [C - `strcat()`示例](https://beginnersbook.com/2017/11/c-strcat-function-with-example/) 2. [C - `strchr()`示例](https://beginnersbook.com/2017/11/c-strchr-function/) 3. [C - `strcmp()`示例](https://beginnersbook.com/2017/11/c-strcmp-function/) 4. [C - `strcoll()`示例](https://beginnersbook.com/2017/11/c-strcoll-function/)
                  <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>

                              哎呀哎呀视频在线观看