-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_strncat.c
51 lines (42 loc) · 1.39 KB
/
ft_strncat.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strncat.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: danalvar <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/10/26 02:17:19 by danalvar #+# #+# */
/* Updated: 2024/10/26 11:39:53 by danalvar ### ########.fr */
/* */
/* ************************************************************************** */
/*#include <stdio.h>*/
int ft_strlen(char *str)
{
int contador;
contador = 0;
while (str[contador] != '\0')
contador++;
return (contador);
}
char *ft_strncat(char *dest, char *src, unsigned int nb)
{
unsigned int i;
unsigned int j;
i = ft_strlen(dest);
j = 0;
while (j < nb && src[j] != '\0')
{
dest[i + j] = src[j];
j++;
}
dest[i + j] = '\0';
return (dest);
}
/*int main(void)
{
char source[] = "Hola";
char destin[] = "Adios";
ft_strncat(destin, source, 5);
printf("%s\n", destin);
return (0);
}*/