-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_printf_str_reverse.c
More file actions
32 lines (29 loc) · 1.15 KB
/
ft_printf_str_reverse.c
File metadata and controls
32 lines (29 loc) · 1.15 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_printf_str_reverse.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: mfrisby <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/07/11 13:15:02 by mfrisby #+# #+# */
/* Updated: 2017/07/11 13:15:04 by mfrisby ### ########.fr */
/* */
/* ************************************************************************** */
#include "libftprintf.h"
char *ft_printf_str_reverse(char *str)
{
int i;
int j;
char *tmp;
i = 0;
j = ft_strlen(str);
if (!(tmp = (char *)malloc(sizeof(char) * (j + 1))))
return (NULL);
tmp[j] = '\0';
while (--j >= 0)
{
tmp[i] = str[j];
i++;
}
return (tmp);
}