-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathft_strrev.c
29 lines (26 loc) · 1.1 KB
/
ft_strrev.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strrev.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: psprawka <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2018/04/10 15:19:21 by psprawka #+# #+# */
/* Updated: 2019/09/14 23:09:13 by psprawka ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strrev(char *str)
{
char *rev;
size_t len;
size_t i;
i = 0;
len = ft_strlen(str);
if (!(rev = ft_strnew(len)))
return (NULL);
while (i < len)
rev[i++] = str[len];
free(str);
return (rev);
}