<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>

                ??碼云GVP開源項目 12k star Uniapp+ElementUI 功能強大 支持多語言、二開方便! 廣告
                # C `strncpy()`函數 > 原文: [https://beginnersbook.com/2017/11/c-strncpy-function/](https://beginnersbook.com/2017/11/c-strncpy-function/) **`strncpy()`函數**類似于[`strcpy()`函數](https://beginnersbook.com/2017/11/c-strcpy-function/),不同之處在于它只從源字符串復制指定數量的字符到目標字符串。 ## C `strncpy()`聲明 ```c char *strncpy(char *str1, const char *str2, size_t n) ``` `str1` - 目標字符串。復制源字符串`str2`的前`n`個字符到其中的字符串。 `str2` - 源字符串 `n - 需要復制的源字符串的字符數。 ## `strncpy()`的返回值 在將源字符串的`n`個字符復制到其中之后,它返回指向目標字符串的指針。 ## 示例:`strncpy()`函數 ```c #include <stdio.h> #include <string.h> int main () { char str1[20]; char str2[25]; /* The first argument in the function is destination string. * In this case we are doing full copy using the strcpy() function. * Here string str2 is destination string in which we are copying the * specified string */ strcpy(str2, "welcome to beginnersbook.com"); /* In this case we are doing a limited copy using the strncpy() * function. We are copying only the 7 characters of string str2 to str1 */ strncpy(str1, str2, 7); printf("String str1: %s\n", str1); printf("String str2: %s\n", str2); return 0; } ``` 輸出: ```c String str1: welcome String str2: welcome to beginnersbook.com ``` #### 相關文章: 1. [C - `strcoll()`函數](https://beginnersbook.com/2017/11/c-strcoll-function/) 2. [C - `strcmp()`函數](https://beginnersbook.com/2017/11/c-strcmp-function/) 3. [C - `strchr()`函數](https://beginnersbook.com/2017/11/c-strchr-function/) 4. [C - `strncat()`函數](https://beginnersbook.com/2017/11/c-strncat-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>

                              哎呀哎呀视频在线观看