creation du main de testing et du test de abs
This commit is contained in:
32
testing/srcs/test_strmap.c
Normal file
32
testing/srcs/test_strmap.c
Normal file
@@ -0,0 +1,32 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_strmap.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: hulamy <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2018/11/14 21:17:49 by hulamy #+# #+# */
|
||||
/* Updated: 2019/03/25 15:23:12 by hulamy ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
/*
|
||||
** create a new array with the result of function f on every element of s
|
||||
*/
|
||||
|
||||
#include "libft.h"
|
||||
|
||||
char *ft_strmap(char const *s, char (*f)(char))
|
||||
{
|
||||
char *str;
|
||||
int i;
|
||||
|
||||
if (!s)
|
||||
return (NULL);
|
||||
if (!(str = ft_strnew(ft_strlen(s))))
|
||||
return (NULL);
|
||||
i = -1;
|
||||
while (s[++i])
|
||||
str[i] = f(s[i]);
|
||||
return (str);
|
||||
}
|
||||
Reference in New Issue
Block a user