-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_strrev.c
40 lines (36 loc) · 1.32 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
30
31
32
33
34
35
36
37
38
39
40
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strrev.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: mbutt <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/03/20 22:15:17 by mbutt #+# #+# */
/* Updated: 2019/03/21 19:17:17 by mbutt ### ########.fr */
/* */
/* ************************************************************************** */
/*
** Takes a string and reverses it.
** RETURN VALUE - Reverse string ending with a null terminator
*/
#include "libft.h"
char *ft_strrev(char *s)
{
int i;
int len;
char *string2;
i = 0;
len = ft_strlen(s);
string2 = (char *)malloc(sizeof(char) * (len + 1));
while (len--)
string2[i++] = s[len];
string2[i] = '\0';
return (string2);
}
/*
** int main (void)
**{
** char string1[] = "ABCD EFGH ijkl";
** printf("%s", ft_strrev(string1));
**}
*/