purge ancien files et mise a jour libftH

This commit is contained in:
Hugo LAMY
2019-11-25 15:46:21 +01:00
parent b6e9b9e5e6
commit 96c7ce814e
182 changed files with 239 additions and 2718 deletions

Binary file not shown.

View File

@@ -6,7 +6,7 @@
/* By: hulamy <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/11/25 13:54:53 by hulamy #+# #+# */
/* Updated: 2019/11/25 13:54:57 by hulamy ### ########.fr */
/* Updated: 2019/11/25 14:28:35 by hulamy ### ########.fr */
/* */
/* ************************************************************************** */
@@ -15,7 +15,7 @@
** a = (int *)malloc(5 * sizeof(int)); //5*4bytes = 20 bytes
** free(a);
** a = (int *)calloc(5, sizeof(int));
**
**
** allocate count * size byte of memory and
** return a pointer to the allocated memory
*/

36
srcs/part1/ft_memccpy.c Normal file
View File

@@ -0,0 +1,36 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_memccpy.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: hulamy <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/11/25 15:24:51 by hulamy #+# #+# */
/* Updated: 2019/11/25 15:25:09 by hulamy ### ########.fr */
/* */
/* ************************************************************************** */
/*
** copy string until character is found and place cursor in dst
** after last byte copied
*/
#include "libft.h"
void *ft_memccpy(void *dst, const void *src, int c, size_t n)
{
unsigned char *dest;
unsigned char *sourc;
size_t i;
i = -1;
dest = (unsigned char *)dst;
sourc = (unsigned char *)src;
while (++i < n)
{
dest[i] = sourc[i];
if (sourc[i] == (unsigned char)c)
return (dst + i + 1);
}
return (NULL);
}

View File

@@ -6,7 +6,7 @@
/* By: hulamy <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/11/25 13:57:02 by hulamy #+# #+# */
/* Updated: 2019/11/25 13:57:05 by hulamy ### ########.fr */
/* Updated: 2019/11/25 14:23:18 by hulamy ### ########.fr */
/* */
/* ************************************************************************** */
@@ -14,55 +14,58 @@
** append src to sized dest and return size of final dest
*/
/*
/*
** #include <libc.h>
**
**
** size_t ft_strlcat(char *dest, const char *src, size_t size);
**
**
** size_t ft_strlcat2(char *dest, char *src, size_t size);
**
**
** int ft_strlen(char *str)
** {
** int i;
**
**
** i = 0;
** while (str[i])
** i++;
** return (i);
** }
**
**
** int main(int ac, char **av)
** {
** char tmp1[100];
** char tmp2[100];
** int i;
**
**
** i = atoi(av[3]);
** strcpy(tmp1, av[1]);
** strcpy(tmp2, av[2]);
**
**
** if (ac == 4)
** {
** printf("----strlcat: %zu - %s - %s\n", strlcat(tmp1, tmp2, i), tmp1, tmp2);
**
** printf("----strlcat: %zu - %s - %s\n", strlcat(tmp1, tmp2, i),
** tmp1, tmp2);
**
** strcpy(tmp1, av[1]);
** strcpy(tmp2, av[2]);
**
** printf("-ft_strlcat: %zu - %s - %s\n", ft_strlcat(tmp1, tmp2, i), tmp1, tmp2);
**
**
** printf("-ft_strlcat: %zu - %s - %s\n", ft_strlcat(tmp1, tmp2, i),
** tmp1, tmp2);
**
** strcpy(tmp1, av[1]);
** strcpy(tmp2, av[2]);
**
** printf("ft_strlcat2: %zu - %s - %s\n", ft_strlcat2(tmp1, tmp2, i), tmp1, tmp2);
**
** printf("ft_strlcat2: %zu - %s - %s\n", ft_strlcat2(tmp1, tmp2, i),
** tmp1, tmp2);
** }
** }
**
**
** size_t ft_strlcat2(char *dest, char *src, size_t size)
** {
** size_t i;
** size_t dest_length;
** size_t src_length;
**
**
** i = 0;
** dest_length = ft_strlen(dest);
** src_length = ft_strlen(src);
@@ -79,7 +82,7 @@
** return (dest_length + src_length);
** return (src_length + size);
** }
*/
*/
#include "libft.h"

View File

@@ -6,28 +6,28 @@
/* By: hulamy <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/11/25 13:57:19 by hulamy #+# #+# */
/* Updated: 2019/11/25 13:57:22 by hulamy ### ########.fr */
/* Updated: 2019/11/25 14:28:12 by hulamy ### ########.fr */
/* */
/* ************************************************************************** */
/*
/*
** copy size - 1 length of src into dest,
** terminate it with a '\0'
** and return size of src
*/
*/
/*
/*
** #include <libc.h>
**
**
** size_t ft_strlcpy(char *dest, const char *src, size_t size);
**
**
** int main(int argc, char **argv)
** {
** char str[100];
** int i;
** unsigned int u;
** unsigned int v;
**
**
** i = atoi(argv[3]);
** strcpy(str, argv[2]);
** if (argc > 3)
@@ -43,7 +43,7 @@
** }
** return (0);
** }
*/
*/
size_t ft_strlcpy(char *dest, const char *src, size_t size)
{