Advertisement
Guest User

Untitled

a guest
Jul 20th, 2019
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. int ft_is_alphanumeric(char c)
  2. {
  3. if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')
  4. || (c >= '0' && c <= '9'))
  5. return (1);
  6. return (0);
  7. }
  8.  
  9. int ft_is_alpha(char c)
  10. {
  11. if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z'))
  12. return (1);
  13. return (0);
  14. }
  15.  
  16. char *ft_strcapitalize(char *str)
  17. {
  18. unsigned int i;
  19.  
  20. if ('a' <= str[0] && str[0] <= 'z')
  21. str[0] = str[0] - 'a' + 'A';
  22. i = 1;
  23. while (str[i] != '\0')
  24. {
  25. if (ft_is_alpha(str[i]))
  26. {
  27. if (ft_is_alphanumeric(str[i - 1]))
  28. {
  29. if ('A' <= str[i] && str[i] <= 'Z')
  30. str[i] = str[i] - 'A' + 'a';
  31. }
  32. else if ('a' <= str[i] && str[i] <= 'z')
  33. str[i] = str[i] - 'a' + 'A';
  34. }
  35. i++;
  36. }
  37. return (str);
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement