Libft and ftprintf added

This commit is contained in:
Angel Ortigosa Perez
2025-11-15 10:31:47 +01:00
parent 5c40a00540
commit a4c1881930
54 changed files with 1809 additions and 105 deletions

42
lib/libft/ft_strrchr.c Normal file
View File

@@ -0,0 +1,42 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strrchr.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: aortigos <aortigos@student.42malaga.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/09/22 18:34:08 by aortigos #+# #+# */
/* Updated: 2023/10/19 16:15:09 by aortigos ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strrchr(const char *str, int c)
{
char x;
size_t i;
i = 0;
x = ((char)c);
while (str[i] != '\0')
{
i++;
}
while (i > 0)
{
if (str[i] == x)
{
return (&((char *)str)[i]);
}
i--;
}
if (i == 0)
{
if (str[i] == x)
{
return (&((char *)str)[i]);
}
}
return (0);
}