ft_strmap.c 1.1 KB

1234567891011121314151617181920212223242526272829
  1. /* ************************************************************************** */
  2. /* */
  3. /* ::: :::::::: */
  4. /* ft_strmap.c :+: :+: :+: */
  5. /* +:+ +:+ +:+ */
  6. /* By: mazimi <mazimi@student.42.fr> +#+ +:+ +#+ */
  7. /* +#+#+#+#+#+ +#+ */
  8. /* Created: 2014/11/10 16:23:57 by mazimi #+# #+# */
  9. /* Updated: 2014/12/02 16:04:38 by mazimi ### ########.fr */
  10. /* */
  11. /* ************************************************************************** */
  12. #include "../libft.h"
  13. char *ft_strmap(char const *s, char (*f)(char))
  14. {
  15. size_t i;
  16. char *str;
  17. if (s != NULL && f != NULL)
  18. {
  19. str = ft_strdup(s);
  20. i = -1;
  21. while (s[++i])
  22. str[i] = f(s[i]);
  23. return (str);
  24. }
  25. return (NULL);
  26. }