-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_ft_strmapi.c
48 lines (44 loc) · 1.61 KB
/
test_ft_strmapi.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* test_ft_strmapi.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jliew <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/07/04 17:13:48 by jliew #+# #+# */
/* Updated: 2020/07/09 23:14:32 by jliew ### ########.fr */
/* */
/* ************************************************************************** */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "libft.h"
char cmap(unsigned int i, char c)
{
return (c + i);
}
int main(int argc, char **argv)
{
if (argc == 1)
{
printf("----------------------------------------------------------------\n");
printf(" char *ft_strmapi(const char *s, char (*f)(unsigned int, char))\n");
printf("----------------------------------------------------------------\n");
printf("usage [manual]:\n");
printf("1. a <string>\n");
}
else
{
char *s;
s = argv[1];
size_t size = ft_strlen(s);
char s2[0XF0];
for (size_t i = 0; i < size; i++)
s2[i] = cmap(i, s[i]);
s2[size] = 0;
char *ret = ft_strmapi(s, cmap);
printf("st: %s\n", s2);
printf("ft: %s\n", ret);
free(ret);
}
}