init
This commit is contained in:
43
Correction/dfdgdf/ex03/ft_strncat.c
Normal file
43
Correction/dfdgdf/ex03/ft_strncat.c
Normal file
@ -0,0 +1,43 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_strncat.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: jmendez <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2022/07/20 22:47:28 by jmendez #+# #+# */
|
||||
/* Updated: 2022/07/25 16:53:34 by cchauvet ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
char *ft_strncat(char *dest, char *src, unsigned int nb)
|
||||
{
|
||||
int i;
|
||||
unsigned int j;
|
||||
|
||||
i = 0;
|
||||
j = 0;
|
||||
while (dest[i] != '\0')
|
||||
i++;
|
||||
while (j < nb)
|
||||
{
|
||||
dest[i] = src[j];
|
||||
i++;
|
||||
j++;
|
||||
}
|
||||
return (dest);
|
||||
}
|
||||
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
char a[] = "sss";
|
||||
char b[] = "aaa";
|
||||
char c[] = "aaa";
|
||||
|
||||
printf("%s", strncat(b, a, 5));
|
||||
printf("\n%s", ft_strncat(c, a, 5));
|
||||
|
||||
}
|
Reference in New Issue
Block a user