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

                合規國際互聯網加速 OSASE為企業客戶提供高速穩定SD-WAN國際加速解決方案。 廣告
                # C 程序:查找字符串的長度 > 原文: [https://www.programiz.com/c-programming/examples/string-length](https://www.programiz.com/c-programming/examples/string-length) #### 在此示例中,您將學習手動查找字符串的長度,而無需使用`strlen()`函數。 要理解此示例,您應該了解以下 [C 編程](/c-programming "C tutorial")主題: * [C 編程字符串](/c-programming/c-strings) * [使用庫函數的 C 編程中的字符串操作](/c-programming/string-handling-functions) * [C `for`循環](/c-programming/c-for-loop) * * * 如您所知,查找字符串長度的最佳方法是使用`strlen()`函數。 但是,在此示例中,我們將手動找到字符串的長度。 * * * ## 不使用`strlen()`函數來計算字符串的長度 ```c #include <stdio.h> int main() { char s[] = "Programming is fun"; int i; for (i = 0; s[i] != '\0'; ++i); printf("Length of the string: %d", i); return 0; } ``` **輸出** ```c Length of the string: 18 ``` 在這里,我們使用`for`循環從`i = 0`到`'\0'`(空字符)循環遍歷字符串。 在每次迭代中,`i`的值增加 1。 循環結束時,字符串的長度將存儲在`i`變量中。
                  <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>

                              哎呀哎呀视频在线观看