-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path02_ft_strcat.c
47 lines (43 loc) · 1.43 KB
/
02_ft_strcat.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* 02_ft_strcat.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: anajmi <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/07/05 12:20:26 by anajmi #+# #+# */
/* Updated: 2021/07/05 14:49:16 by anajmi ### ########.fr */
/* */
/* ************************************************************************** */
#include <stdio.h>
#include <string.h>
char *ft_strcat(char *dest, char *src)
{
unsigned int i;
unsigned int a;
i = 0;
while (dest[i] != '\0')
i++;
a = 0;
while (src[a] != '\0')
{
dest[i + a] = src[a];
a++;
}
dest[i + a] = '\0';
return (dest);
}
int main(void)
{
char str1[100] = "This is ", str2[] = "cluster e1";
// concatenates str1 and str2
// the resultant string is stored in str1.
ft_strcat(str1, str2);
puts(str1);
puts(str2);
char str3[100] = "This is ", str4[] = "cluster e1";
strcat(str3, str4);
puts(str3);
puts(str4);
return (0);
}