text: /* ************************************************************************** */
  /*                                                                            */
  /*                                                        :::      ::::::::   */
  /*   ft_strmapi.c                                       :+:      :+:    :+:   */
  /*                                                    +:+ +:+         +:+     */
  /*   By: kangkim <kangkim@student.42seoul.kr>       +#+  +:+       +#+        */
  /*                                                +#+#+#+#+#+   +#+           */
  /*   Created: 2021/11/18 15:27:59 by kangkim           #+#    #+#             */
  /*   Updated: 2021/11/18 15:31:53 by kangkim          ###   ########.fr       */
  /*                                                                            */
  /* ************************************************************************** */
  
  #include "libft.h"
  
  char	*ft_strmapi(char const *s, char (*f)(unsigned int, char))
  {
  	unsigned int	len;
  	char			*str;
  	unsigned int	idx;
  
  	if (!s || !f)
  		return (NULL);
  	len = ft_strlen(s);
  	str = (char *)malloc(sizeof(char) * (len + 1));
  	if (!str)
  		return (NULL);
  	idx = 0;
  	while (s[idx])
  	{
  		str[idx] = (*f)(idx, s[idx]);
  		idx++;
  	}
  	str[idx] = '\0';
  	return (str);
  }
  