This commit is contained in:
Camille Chauvet
2023-05-17 16:45:25 +00:00
commit 29ed24d567
619 changed files with 16119 additions and 0 deletions

View File

@ -0,0 +1,42 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strncpy.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: thellego <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/07/17 09:22:49 by thellego #+# #+# */
/* Updated: 2022/07/20 10:53:02 by cchauvet ### ########.fr */
/* */
/* ************************************************************************** */
char *ft_strncpy(char *dest, char *src, unsigned int n)
{
unsigned int counter;
counter = 0;
while (counter < n && src[counter] != '\0')
{
dest[counter] = src[counter];
counter++;
}
while (counter < n)
{
dest[counter] = '\0';
counter++;
}
if (src[counter] == '\0')
dest[counter] = '\0';
return (dest);
}
#include <stdio.h>
int main()
{
char tab1[120] = "hello world jjhaflhsuid ai;eiwjejvhds jdg";
char tab[120] = "";
printf("%s\n", tab);
ft_strncpy(tab, tab1, 10);
printf("%s\n", tab1);
printf("%s\n", tab);
}