-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathft_strrevnew.c
38 lines (35 loc) · 1.18 KB
/
ft_strrevnew.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strrevnew.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: smbaabu <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/03/21 19:48:51 by smbaabu #+# #+# */
/* Updated: 2019/03/25 15:58:11 by smbaabu ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strrevnew(char *s)
{
char *ret;
int len;
int i;
len = ft_strlen(s);
if ((ret = ft_strnew(len)) == NULL)
return (NULL);
if (len > 0)
{
i = 0;
len--;
while (i < len)
{
ret[i] = s[len];
ret[len] = s[i];
i++;
len--;
}
ret[i] = s[i];
}
return (ret);
}