55 lines
1.6 KiB
C
55 lines
1.6 KiB
C
/* ************************************************************************** */
|
|
/* */
|
|
/* ::: :::::::: */
|
|
/* ft_strcat.c :+: :+: :+: */
|
|
/* +:+ +:+ +:+ */
|
|
/* By: whaffman <whaffman@student.codam.nl> +#+ +:+ +#+ */
|
|
/* +#+#+#+#+#+ +#+ */
|
|
/* Created: 2024/06/11 14:58:48 by whaffman #+# #+# */
|
|
/* Updated: 2024/06/11 15:00:16 by whaffman ### ########.fr */
|
|
/* */
|
|
/* ************************************************************************** */
|
|
|
|
#include <stdio.h>
|
|
#include <string.h>
|
|
|
|
char *ft_strcat(char *dest, char *src)
|
|
{
|
|
char *odest;
|
|
|
|
odest = dest;
|
|
while (*dest)
|
|
dest++;
|
|
while (*src)
|
|
*dest++ = *src++;
|
|
*dest = '\0';
|
|
return (odest);
|
|
}
|
|
|
|
#ifdef DEBUG
|
|
|
|
void test(char *s1, char *s2, char *s3)
|
|
{
|
|
printf("s1: \"%s\"\n", s1);
|
|
printf("s2: \"%s\"\n", s2);
|
|
printf("s3: \"%s\"\n", s3);
|
|
printf("strcat(s1, s3): \"%s\"\nft_strcat(s2, s3): \"%s\"\n\n", \
|
|
strcat(s1, s3), ft_strcat(s2, s3));
|
|
}
|
|
|
|
int main(void)
|
|
{
|
|
char s1[20];
|
|
char s2[20];
|
|
|
|
s1[0] = '\0';
|
|
test(&s1[0], &s2[0], "Hello!");
|
|
test(&s1[0], &s2[0], "Hello!");
|
|
test(&s1[0], &s2[0], "Hello!");
|
|
test(&s1[0], &s2[0], "Hello!");
|
|
test(&s1[0], &s2[0], "Hello!");
|
|
test(&s1[0], &s2[0], "Hello!");
|
|
return (0);
|
|
}
|
|
#endif
|