Advertisement
Vitamin4eg

Untitled

Oct 22nd, 2018
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. char *ft_strcapitalize(char *str)
  2. {
  3. unsigned int i;
  4.  
  5. if (str[0] != '\0' && str[0] >= 'a' && str[0] <= 'z')
  6. str[0] -= 32;
  7. i = 1;
  8. while (str[i] != '\0')
  9. {
  10. if (((str[i] >= 'a' && str[i] <= 'z') ||
  11. (str[i] >= 'A' && str[i] <= 'Z')) &&
  12. (str[i - 1] < '0' ||
  13. (str[i - 1] > '9' && str[i - 1] < 'A') ||
  14. (str[i - 1] > 'Z' && str[i - 1] < 'a') ||
  15. str[i - 1] > 'z'))
  16. {
  17. if (str[i] >= 'a' && str[i] <= 'z')
  18. str[i] -= 32;
  19. }
  20. else if (str[i] >= 'A' && str[i] <= 'Z')
  21. str[i] += 32;
  22. ++i;
  23. }
  24. return (str);
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement