cub3d/libft/src/ft_revstr.c
2023-10-25 13:56:45 +02:00

34 lines
1.1 KiB
C

/* ************************************************************************** */
/* */
/* :::::::: */
/* ft_revstr.c |o_o || | */
/* +:+ */
/* By: djonker <marvin@codam.nl> +#+ */
/* +#+ */
/* Created: 2021/01/18 11:54:50 by djonker #+# #+# */
/* Updated: 2023/03/05 20:39:52 by houtworm \___)=(___/ */
/* */
/* ************************************************************************** */
#include "../libft.h"
char *ft_revstr(char *s)
{
char *r;
int is;
int ir;
r = ft_calloc(8 * (ft_strlen(s) + 1), 1);
is = ft_strlen(s) - 1;
ir = 0;
while (is >= 0)
{
r[ir] = s[is];
ir++;
is--;
}
r[ir] = '\0';
s = r;
return (r);
}