minishell
ft_strmapi.c File Reference
#include "ft_string.h"
Include dependency graph for ft_strmapi.c:

Go to the source code of this file.

Functions

char * ft_strmapi (char const *s, char(*f)(unsigned int, char))
 

Function Documentation

◆ ft_strmapi()

char* ft_strmapi ( char const *  s,
char(*)(unsigned int, char)  f 
)

Definition at line 15 of file ft_strmapi.c.

16 {
17  char *p_ret;
18  size_t index;
19 
20  if (s == NULL || *s == '\0')
21  return (ft_strdup(""));
22  p_ret = ft_strdup(s);
23  if (f == NULL || p_ret == NULL)
24  return (p_ret);
25  index = 0;
26  while (*s != '\0')
27  {
28  p_ret[index] = f(index, *s++);
29  index++;
30  }
31  return (p_ret);
32 }
char * ft_strdup(const char *s1)
Definition: ft_strdup.c:16
Here is the call graph for this function: