Advertisement
Guest User

Untitled

a guest
Jan 19th, 2020
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.60 KB | None | 0 0
  1. //
  2. //  main.cpp
  3. //  zad_2
  4. //
  5. //  Created by Rafał Hrabia on 19/01/2020.
  6. //  Copyright © 2020 Rafał Hrabia. All rights reserved.
  7. //
  8.  
  9. #include <iostream>
  10. #include <cctype>
  11.  
  12. using namespace std;
  13.  
  14. char*foo(char*str, int length) {
  15.    
  16.     for(int i = 0; str[i]; i++) {
  17.         if (isupper(str[i])) str[i] = tolower(str[i]);
  18.         else if ( islower(str[i]) && (i == 0 || isspace(str[i-1]))) str[i] = toupper(str[i]);
  19.     }
  20.    
  21.     return str;
  22. }
  23.  
  24. int main(int argc, const char * argv[]) {
  25.    
  26.     char str[50] = "Dark Side of the Moon";
  27.     cout << foo(str, 50) << endl;
  28.     return 0;
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement