63 lines
1.4 KiB
C
63 lines
1.4 KiB
C
/* ************************************************************************** */
|
|
/* */
|
|
/* ::: :::::::: */
|
|
/* utilities.c :+: :+: :+: */
|
|
/* +:+ +:+ +:+ */
|
|
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
|
|
/* +#+#+#+#+#+ +#+ */
|
|
/* Created: 2016/08/20 11:47:17 by jhalford #+# #+# */
|
|
/* Updated: 2016/08/21 18:46:37 by jhalford ### ########.fr */
|
|
/* */
|
|
/* ************************************************************************** */
|
|
|
|
#include <stdlib.h>
|
|
#include <stdio.h>
|
|
|
|
char *ft_strcat(char *dest, char *src)
|
|
{
|
|
int i;
|
|
int j;
|
|
|
|
i = 0;
|
|
while (dest[i] != '\0')
|
|
i++;
|
|
j = 0;
|
|
while (src[j] != '\0')
|
|
{
|
|
dest[i] = src[j];
|
|
i++;
|
|
j++;
|
|
}
|
|
dest[i] = '\0';
|
|
return (dest);
|
|
}
|
|
|
|
char *ft_strdup(char *src)
|
|
{
|
|
char *dup;
|
|
int size;
|
|
int i;
|
|
|
|
i = 0;
|
|
size = 0;
|
|
while (src[size] != '\0')
|
|
size++;
|
|
dup = (char*)malloc(sizeof(*dup) * (size + 1));
|
|
while (src[i] != '\0')
|
|
{
|
|
dup[i] = src[i];
|
|
i++;
|
|
}
|
|
dup[i] = '\0';
|
|
return (dup);
|
|
}
|
|
|
|
int ft_strlen(char *str)
|
|
{
|
|
int i;
|
|
|
|
i = 0;
|
|
while (str[i])
|
|
i++;
|
|
return (i);
|
|
}
|