-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmy_strlcat.c
50 lines (43 loc) · 1.05 KB
/
my_strlcat.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
#include "libft.h"
static long unsigned int my_own_strlen(const char *str)
{
int count;
count = 0;
while (str[count] != '\0')
count++;
return (count);
}
size_t my_strlcat(char *dst, const char *src, size_t size)
{
unsigned long int id;
unsigned long int is;
id = 0;
is = 0;
while (id < size && dst[id])
id++;
while (src[is] != '\0' && id + is + 1 < size)
{
dst[id + is] = src[is];
is++;
}
if (id != size)
dst[id + is] = '\0';
return (id + my_own_strlen(src));
}
/*
#include <bsd/string.h>
int main()
{
unsigned long int st;
char dst1[200] = "Continue a nadar, continue a nadar, nadar, nadar...";
char src1[] = "Pra achar a solução... Nadar!";
unsigned int n = 10;
st = my_strlcat(dst1, src1, n);
printf("\n Minha my_strlcat(): %s\n", dst1);
printf("Meu retorno: %lu \n\n", st);
char str3[200] = "Continue a nadar, continue a nadar, nadar, nadar...";
char str4[] = "Pra achar a solução... Nadar!";
st = strlcat(str3, str4, n);
printf("strlcat() original: %s\n", str3);
printf("Retorno original: %lu \n\n", st);
}*/