skeletton untested project
This commit is contained in:
commit
6fc620e8f4
187 changed files with 6584 additions and 0 deletions
35
libft/ft_strmapi.c
Executable file
35
libft/ft_strmapi.c
Executable file
|
|
@ -0,0 +1,35 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_strmapi.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: thrieg <thrieg@student.42mulhouse.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/10/15 16:38:47 by thrieg #+# #+# */
|
||||
/* Updated: 2025/02/16 19:04:54 by thrieg ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "libft.h"
|
||||
|
||||
//I don't know if I have to apply the function to the ending null char...
|
||||
//return NULL if any argument is NULL or if any allocation fails
|
||||
char *ft_strmapi(char const *s, char (*f)(unsigned int, char))
|
||||
{
|
||||
char *ret;
|
||||
unsigned int i;
|
||||
|
||||
if (!s || !f)
|
||||
return (NULL);
|
||||
ret = malloc(sizeof(char) * (ft_strlen(s) + 1));
|
||||
if (!ret)
|
||||
return (NULL);
|
||||
i = 0;
|
||||
while (s[i])
|
||||
{
|
||||
ret[i] = f(i, s[i]);
|
||||
i++;
|
||||
}
|
||||
ret[i] = '\0';
|
||||
return (ret);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue