This commit is contained in:
Timo Schmidt 2023-03-29 01:28:41 +02:00
parent 6ef246128d
commit a811adb340
2 changed files with 14 additions and 11 deletions

View File

@ -6,14 +6,14 @@
/* By: tischmid <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/03/24 02:01:33 by tischmid #+# #+# */
/* Updated: 2023/03/28 18:55:41 by tischmid ### ########.fr */
/* Updated: 2023/03/29 01:04:03 by tischmid ### ########.fr */
/* */
/* ************************************************************************** */
int ft_strncmp(char *s1, char *s2, unsigned int n)
{
if (!n)
return (1);
return (0);
while (*s1 && *s2 && *s1 == *s2 && --n)
{
++s1;
@ -24,8 +24,8 @@ int ft_strncmp(char *s1, char *s2, unsigned int n)
/* ////
#include <stdio.h>
#define STR1 "abd"
#define STR2 "abc"
#define STR1 "a"
#define STR2 "a"
#define LENGTH 0
int main(void)

View File

@ -6,7 +6,7 @@
/* By: tischmid <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/03/24 03:19:16 by tischmid #+# #+# */
/* Updated: 2023/03/28 17:23:27 by tischmid ### ########.fr */
/* Updated: 2023/03/29 01:01:23 by tischmid ### ########.fr */
/* */
/* ************************************************************************** */
@ -14,7 +14,7 @@
unsigned int ft_strlcat(char *dest, char *src, unsigned int size)
{
unsigned int dest_src_size;
unsigned int ret_size;
unsigned int i;
char *o_src;
@ -22,24 +22,27 @@ unsigned int ft_strlcat(char *dest, char *src, unsigned int size)
i = 0;
while (*dest++)
++i;
dest_src_size = i;
ret_size = i;
if (i > size)
ret_size = size;
--dest;
while (++i < size && *src)
*dest++ = *src++;
*dest = 0;
while (*o_src++)
++dest_src_size;
return (dest_src_size);
++ret_size;
return (ret_size);
}
/* ////
#include <stdio.h>
#include <bsd/string.h>
int main(void)
{
char s[10] = "123";
char s[10] = "aaaa";
printf("%d\n", ft_strlcat(s, "abc", 5));
printf("%d\n", ft_strlcat(s, "xyz", 16));
printf("%s\n", s);
return (0);
}