text: /* ************************************************************************** */
  /*                                                                            */
  /*                                                        :::      ::::::::   */
  /*   ft_strmapi.c                                       :+:      :+:    :+:   */
  /*                                                    +:+ +:+         +:+     */
  /*   By: geliz <marvin@42.fr>                       +#+  +:+       +#+        */
  /*                                                +#+#+#+#+#+   +#+           */
  /*   Created: 2019/09/15 14:54:41 by geliz             #+#    #+#             */
  /*   Updated: 2019/09/21 20:20:39 by geliz            ###   ########.fr       */
  /*                                                                            */
  /* ************************************************************************** */
  
  #include "libft.h"
  #include <stdlib.h>
  
  char	*ft_strmapi(char const *s, char (*f)(unsigned int, char))
  {
  	size_t	i;
  	char	*str;
  
  	if (s == NULL)
  		return (NULL);
  	i = ft_strlen((char *)s);
  	str = malloc(sizeof(char) * (i + 1));
  	if (str == NULL)
  		return (NULL);
  	i = 0;
  	while (s[i] != '\0')
  	{
  		str[i] = f(i, (((char *)s)[i]));
  		i++;
  	}
  	str[i] = '\0';
  	return (str);
  }
  