ft_strmap
This commit is contained in:
parent
a3462b7b10
commit
0c3c65034c
9
Makefile
9
Makefile
@ -3,10 +3,10 @@
|
|||||||
# ::: :::::::: #
|
# ::: :::::::: #
|
||||||
# Makefile :+: :+: :+: #
|
# Makefile :+: :+: :+: #
|
||||||
# +:+ +:+ +:+ #
|
# +:+ +:+ +:+ #
|
||||||
# By: tmaze <marvin@42.fr> +#+ +:+ +#+ #
|
# By: tmaze <tmaze@student.42.fr> +#+ +:+ +#+ #
|
||||||
# +#+#+#+#+#+ +#+ #
|
# +#+#+#+#+#+ +#+ #
|
||||||
# Created: 2018/04/04 10:51:59 by tmaze #+# #+# #
|
# Created: 2018/04/07 12:47:06 by tmaze #+# #+# #
|
||||||
# Updated: 2018/04/07 11:42:48 by tmaze ### ########.fr #
|
# Updated: 2018/04/07 12:47:09 by tmaze ### ########.fr #
|
||||||
# #
|
# #
|
||||||
#******************************************************************************#
|
#******************************************************************************#
|
||||||
|
|
||||||
@ -51,7 +51,8 @@ SRCS = \
|
|||||||
ft_strdel.c \
|
ft_strdel.c \
|
||||||
ft_strclr.c \
|
ft_strclr.c \
|
||||||
ft_striter.c \
|
ft_striter.c \
|
||||||
ft_striteri.c
|
ft_striteri.c \
|
||||||
|
ft_strmap.c
|
||||||
OBJS = $(SRCS:.c=.o)
|
OBJS = $(SRCS:.c=.o)
|
||||||
INCLS = -I.
|
INCLS = -I.
|
||||||
|
|
||||||
|
27
ft_strmap.c
Normal file
27
ft_strmap.c
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* ft_strmap.c :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: tmaze <tmaze@student.42.fr> +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* Created: 2018/04/07 12:35:16 by tmaze #+# #+# */
|
||||||
|
/* Updated: 2018/04/07 13:04:23 by tmaze ### ########.fr */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
#include "libft.h"
|
||||||
|
|
||||||
|
char *ft_strmap(char const *s, char (*f)(char))
|
||||||
|
{
|
||||||
|
char *ret;
|
||||||
|
size_t i;
|
||||||
|
size_t s_len;
|
||||||
|
|
||||||
|
i = -1;
|
||||||
|
s_len = ft_strlen(s);
|
||||||
|
ret = ft_strnew(s_len);
|
||||||
|
while (++i < s_len)
|
||||||
|
ret[i] = (*f)(s[i]);
|
||||||
|
return (ret);
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user