printf/libft/ft_strmapi.c
/* applies the given function f to each char of the str.
* in order to create a new string that is the resulst of the function
* f run on string s. 
* starts by creating an i count and a char to store the value returned
* alloc memory. Add +1 to make sure it ends on a null.
* if fail return NULL.
* Iterates through s and applys f to each char.
* then return the filled string.
*/
applies the given function f to each char of the str.
in order to create a new string that is the resulst of the function
f run on string s.
starts by creating an i count and a char to store the value returned
alloc memory. Add +1 to make sure it ends on a null.
if fail return NULL.
Iterates through s and applys f to each char.
then return the filled string.
applies the given function f to each char of the str . in order to create a new string that is the resulst of the function f run on string s . starts by creating an i count and a char to store the value returned alloc memory . Add + 1 to make sure it ends on a null . if fail return NULL . Iterates through s and applys f to each char . then return the filled string .
char	*ft_strmapi(char const *s, char (*f)(unsigned int, char))
{
	unsigned int	i;
	char			*str;
	i = 0;
	str = (char *)malloc(sizeof(char) * (ft_strlen(s)) + 1);
	if (str == NULL)
		return (NULL);
	while (s[i] != '\0')
	{
		str[i] = f(i, s[i]);
		i++;
	}
	str[i] = '\0';
	return (str);
}
char * ft_strmapi ( char const * s , char ( * f ) ( unsigned int , char ) ) { unsigned int i ; char * str ; i = 0 ; str = ( char * ) malloc ( sizeof ( char ) * ( ft_strlen ( s ) ) + 1 ) ; if ( str == NULL ) return ( NULL ) ; while ( s [ i ] != ' \0 ' ) { str [ i ] = f ( i , s [ i ] ) ; i ++ ; } str [ i ] = ' \0 ' ; return ( str ) ; }
applies the given function f to each char of the str.
applies the given function f to each char of the str .