1
0
This repository has been archived on 2024-10-25. You can view files and clone it, but cannot push or open issues or pull requests.
2023-08-03 23:16:27 +02:00

76 lines
1.6 KiB
C

/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* lib.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: adjoly <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/07/29 12:52:50 by adjoly #+# #+# */
/* Updated: 2023/07/30 20:02:25 by tomoron ### ########.fr */
/* */
/* ************************************************************************** */
#include "header.h"
t_ulli ft_strlen(char *str)
{
t_ulli i;
i = 0;
while (str[i])
i++;
return (i);
}
void ft_putchar(char charac)
{
write(1, &charac, 1);
}
void ft_putstr(char *str)
{
t_ulli i;
i = 0;
while (str[i])
{
ft_putchar(str[i]);
i++;
}
}
int ft_strcmp(char *s1, char *s2)
{
t_ulli i;
i = 0;
while (s1[i] || s2[i])
{
if (s1[i] != s2[i])
return (s1[i] - s2[i]);
i++;
}
return (s1[i] - s2[i]);
}
char *ft_strndup(char *src, t_ulli n)
{
char *res;
t_ulli len;
t_ulli i;
len = ft_strlen(src);
i = 0;
res = malloc((len + 1) + sizeof(char));
if (res)
{
while (src[i] && i < n)
{
res[i] = src[i];
i++;
}
res[i] = 0;
}
return (res);
}