style: reoarginsed the file and fix the makefile
This commit is contained in:
parent
ecd9608320
commit
a5fe7484a1
46 changed files with 140 additions and 49 deletions
34
str/ft_strmapi.c
Normal file
34
str/ft_strmapi.c
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_strmapi.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/11/09 13:56:57 by rparodi #+# #+# */
|
||||
/* Updated: 2023/11/13 19:49:30 by rparodi ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "libft.h"
|
||||
|
||||
char *ft_strmapi(char const *s, char (*f)(unsigned int, char))
|
||||
{
|
||||
size_t i;
|
||||
size_t len;
|
||||
char *str;
|
||||
|
||||
i = 0;
|
||||
len = ft_strlen(s);
|
||||
str = (char *)malloc(len + 1);
|
||||
if (!str)
|
||||
return (NULL);
|
||||
else
|
||||
ft_bzero((char *)str, len + 1);
|
||||
while (i < len)
|
||||
{
|
||||
str[i] = f(i, s[i]);
|
||||
i++;
|
||||
}
|
||||
return (str);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue