<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 程序:刪除字符串中除字母之外的所有字符 > 原文: [https://www.programiz.com/c-programming/examples/remove-characters-string](https://www.programiz.com/c-programming/examples/remove-characters-string) #### 在此示例中,您將學習從用戶輸入的字符串中刪除除字母之外的所有字符。 要理解此示例,您應該了解以下 [C 編程](/c-programming "C tutorial")主題: * [C 數組](/c-programming/c-arrays) * [C 編程字符串](/c-programming/c-strings) * [C `for`循環](/c-programming/c-for-loop) * [C `while`和`do...while`循環](/c-programming/c-do-while-loops) * * * ## 刪除字符串中除字母之外的字符 ```c #include <stdio.h> int main() { char line[150]; printf("Enter a string: "); fgets(line, sizeof(line), stdin); // take input for (int i = 0, j; line[i] != '\0'; ++i) { // enter the loop if the character is not an alphabet // and not the null character while (!(line[i] >= 'a' && line[i] <= 'z') && !(line[i] >= 'A' && line[i] <= 'Z') && !(line[i] == '\0')) { for (j = i; line[j] != '\0'; ++j) { // if jth element of line is not an alphabet, // assign the value of (j+1)th element to the jth element line[j] = line[j + 1]; } line[j] = '\0'; } } printf("Output String: "); puts(line); return 0; } ``` **輸出** ```c Enter a string: p2'r-o@gram84iz./ Output String: programiz ``` * * * 該程序從用戶處獲取一個字符串輸入,并將其存儲在`line`變量中。 然后,使用`for`循環迭代字符串的字符。 如果字符串中的字符不是字母,則將其從字符串中刪除,其余字符的位置向左移動 1 個位置。
                  <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>

                              哎呀哎呀视频在线观看