SHARE
TWEET

Func toUpperCase() and toLowerCase()

daniil_mironoff Dec 9th, 2018 75 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. char * toUpperCase(char * stroka) {
  5.     char * new_stroka = new char[1];
  6.     for (int i = 0; stroka[i] != 0; i++) {
  7.         if (stroka[i] >= 97 && stroka[i] <= 122) {
  8.             new_stroka[i] = stroka[i] - 32;
  9.         } else {
  10.             new_stroka[i] = stroka[i];
  11.         }
  12.     }
  13.    
  14.     return new_stroka;
  15. }
  16.  
  17. char * toLowerCase(char * stroka) {
  18.     char * new_stroka = new char[1];
  19.     for (int i = 0; stroka[i] != 0; i++) {
  20.         if (stroka[i] >= 65 && stroka[i] <= 90) {
  21.             new_stroka[i] = stroka[i] + 32;
  22.         } else {
  23.             new_stroka[i] = stroka[i];
  24.         }
  25.     }
  26.    
  27.     return new_stroka;
  28. }
  29.  
  30. int main() {
  31.     char * test_strokaoka = "FatCat";
  32.    
  33.     cout << test_strokaoka << endl;
  34.     cout << toUpperCase(test_strokaoka) << endl;
  35.     cout << toLowerCase(test_strokaoka) << endl;
  36.     return 0;
  37. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top