c語言代碼編程題匯總:將字串中的大寫字母轉換成小寫字母

來源:互聯網
上載者:User

標籤:ring   while   stdio.h   res   c語言   int   字母   inpu   dsd   

將字串中的大寫字母轉換成小寫字母

  程式碼如下:

 1 /* 2     2017年3月8日21:21:46 3     功能:將字串中的大寫字母轉換成小寫字母 4 */ 5 /* 6 #include"stdio.h" 7  8 int main() 9 {10     int n = 0;11 12     char a[100];13 14     printf("please input a string:");15 16     gets(a);17 18     for(int i = 0 ;a[i] != ‘\0‘;i++)19     {20 21         n++;22 23     }24 25     for(int j = 0;j < n ; j++)26     {27 28         if (a[j] >= ‘A‘&& a[j] <= ‘Z‘)29         {30 31             a[j] = a[j] + 32;32 33         }34     35     }36 37     puts(a);38 39 }*/40 41 #include"stdio.h"42 43 int main()44 {45     char a[100];46 47     char *p = a;48 49     printf("please input a string: \n");50 51     gets(a);52 53     while(*p)54     {55 56         if(*p >= ‘A‘&& *p <= ‘Z‘)57         {58 59             *p = *p + 32;60 61         }62 63         p++;64     65     }66     printf("the result is: \n");67     puts(a);68 }69 /*70     總結:71     在VC++6.0中顯示的結果:72     ——————————————————————————————73     please input a string:74     ASDsdffgj75     the result is:76     asdsdffgj77     ——————————————————————————————78 */

 

c語言代碼編程題匯總:將字串中的大寫字母轉換成小寫字母

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.