Advertisement
daniil_mironoff

Func toUpperCase() and toLowerCase()

Dec 9th, 2018
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.89 KB | None | 0 0
  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. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement