-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft2_ftparam.c
58 lines (50 loc) · 1.46 KB
/
ft2_ftparam.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft2_ftparam.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: lpalacio <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/09/30 14:14:31 by lpalacio #+# #+# */
/* Updated: 2022/09/30 14:15:57 by lpalacio ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strmapi(char const *s, char (*f)(unsigned int, char))
{
char *str;
unsigned int i;
i = 0;
str = ft_strdup(s);
if (str == NULL)
return (NULL);
while (str[i] != 0)
{
str[i] = f(i, str[i]);
i++;
}
return (str);
}
void ft_striteri(char *s, void (*f)(unsigned int, char*))
{
int i;
i = 0;
while (s[i] != 0)
{
f(i, s + i);
i++;
}
}
void ft_putchar_fd(char c, int fd)
{
write (fd, &c, 1);
}
void ft_putstr_fd(char *s, int fd)
{
write (fd, s, ft_strlen(s));
}
void ft_putendl_fd(char *s, int fd)
{
ft_putstr_fd(s, fd);
write (fd, "\n", 1);
}