Board logo

標題: 字串處理 (五) - 英文大小寫轉換 [打印本頁]

作者: 鄭繼威    時間: 2023-3-8 20:12     標題: 字串處理 (五) - 英文大小寫轉換

本帖最後由 鄭繼威 於 2023-3-8 21:07 編輯

運用 strupr() 函式 與 strlwr() 函式進行英文大小寫轉換.
<string.h> 標頭檔
strupr()->string upper 字串大寫
strlwr()->string lower 字串小寫


  1. #include<iostream>
  2. #include<cstdlib>
  3. #include<string.h>
  4. using namespace std;
  5. int main()
  6. {
  7.     char str[50];
  8.     cout<<"輸入一字串: ";
  9.     cin.getline(str,50);
  10.     strupr(str);   //string upper
  11.     cout<<"轉為大寫: "<<str<<endl;
  12.     strlwr(str);   //string lower
  13.     cout<<"轉為小寫: "<<str<<endl;
  14.     system("pause");     
  15.     return 0;   
  16. }
複製代碼

作者: 林劭杰    時間: 2023-3-8 21:11

  1. #include<iostream>
  2. #include<cstdlib>
  3. #include<string.h>
  4. using namespace std;
  5. int main()
  6. {
  7.     char str[50];
  8.     cout<<"輸入一字串: ";
  9.     cin.getline(str,50);strupr(str);
  10.       
  11.     cout<<"轉為大寫:"<<str<<endl;strlwr(str);
  12.    
  13.     cout<<"轉為小寫:"<<str<<endl;
  14.     system("pause");     
  15.     return 0;   
  16. }
複製代碼

作者: 李彣    時間: 2023-3-8 21:11

  1. #include<iostream>
  2. #include<cstdlib>
  3. #include<string.h>
  4. using namespace std;
  5. int main()
  6. {
  7.     char str[50];
  8.     cout<<"輸入一字串: ";
  9.     cin.getline(str,50);
  10.     strupr(str);
  11.     cout<<"轉為大寫"<<str<<endl;;
  12.     strlwr(str);
  13.     cout<<"轉為小寫"<<str<<endl;;
  14.     system("pause");
  15.     return 0;
  16. }
複製代碼

作者: 黃裕恩    時間: 2023-3-8 21:14

  1. #include<iostream>
  2. #include<cstdlib>
  3. #include<string.h>
  4. using namespace std;
  5. int main()
  6. {
  7.     char str[50];
  8.     cout<<"輸入一字串: ";
  9.     cin.getline(str,50);
  10.     strupr(str);   
  11.     cout<<"轉為大寫: "<<str<<endl;
  12.     strlwr(str);   
  13.     cout<<"轉為小寫: "<<str<<endl;
  14.     system("pause");     
  15.     return 0;   
  16. }
複製代碼

作者: 林劭澧    時間: 2023-3-8 21:14

  1. #include<iostream>
  2. #include<cstdlib>
  3. #include<string.h>
  4. using namespace std;
  5. int main()
  6. {
  7.      char str[50];
  8.     cout<<"輸入字串: ";
  9.     cin.getline(str,50);
  10.     strupr(str);   
  11.     cout<<"轉大寫: "<<str<<endl;
  12.     strlwr(str);   
  13.     cout<<"轉小寫: "<<str<<endl;
  14.     system("pause");     
  15.     return 0;   
  16. }
複製代碼





歡迎光臨 種子論壇 | 高雄市資訊培育協會學員討論區 (http://seed.istak.org.tw/) Powered by Discuz! 7.2