-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_strrev.c
More file actions
41 lines (36 loc) · 1.19 KB
/
ft_strrev.c
File metadata and controls
41 lines (36 loc) · 1.19 KB
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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strrev.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: knzeng-e <knzeng-e@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/03/24 01:05:00 by knzeng-e #+# #+# */
/* Updated: 2016/04/01 05:09:49 by knzeng-e ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
static int ft_len(char *str)
{
int i;
i = 0;
while (str[i])
i++;
return (i);
}
char *ft_strrev(char *str)
{
int i;
int j;
char *out;
i = ft_len(str);
out = (char *)malloc(sizeof(char) * i);
if (out)
{
j = 0;
out[i] = '\0';
while (--i >= 0)
out[i] = str[j++];
}
return (out);
}