64 lines
1.5 KiB
C
64 lines
1.5 KiB
C
/* ************************************************************************** */
|
|
/* */
|
|
/* ::: :::::::: */
|
|
/* ft_strlib.c :+: :+: :+: */
|
|
/* +:+ +:+ +:+ */
|
|
/* By: tischmid <marvin@42.fr> +#+ +:+ +#+ */
|
|
/* +#+#+#+#+#+ +#+ */
|
|
/* Created: 2023/04/01 07:13:31 by tischmid #+# #+# */
|
|
/* Updated: 2023/04/02 18:38:52 by tischmid ### ########.fr */
|
|
/* */
|
|
/* ************************************************************************** */
|
|
|
|
#include "ft_strlib.h"
|
|
|
|
int ft_strcmp(char *s1, char *s2)
|
|
{
|
|
while (*s1 && *s2 && *s1 == *s2)
|
|
{
|
|
++s1;
|
|
++s2;
|
|
}
|
|
return (*s1 - *s2);
|
|
}
|
|
|
|
char *ft_strcpy(char *dest, char *src)
|
|
{
|
|
char *o_dest;
|
|
|
|
o_dest = dest;
|
|
while (*src)
|
|
*dest++ = *src++;
|
|
*dest = 0;
|
|
return (o_dest);
|
|
}
|
|
|
|
int ft_strlen(char *str)
|
|
{
|
|
int i;
|
|
|
|
i = 0;
|
|
while (*str++)
|
|
++i;
|
|
return (i);
|
|
}
|
|
|
|
int ft_isspace(char c)
|
|
{
|
|
return (c == ' '
|
|
|| c == '\t'
|
|
|| c == '\v'
|
|
|| c == '\n'
|
|
|| c == '\r'
|
|
|| c == '\f');
|
|
}
|
|
|
|
char *last_non_whitespace(char *ptr)
|
|
{
|
|
while (*ptr)
|
|
++ptr;
|
|
while (ft_isspace(*ptr))
|
|
--ptr;
|
|
return (ptr);
|
|
}
|