-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcustom_1.c
57 lines (49 loc) · 887 Bytes
/
custom_1.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
51
52
53
54
55
56
57
#include "shell.h"
/**
* str_len - A Function to find the length a string.
* @str: string to count.
*
* Return: Number of characters.
*/
int str_len(char *str)
{
int len = 0;
while (str[len] != '\0')
{
len++;
}
return (len);
}
/**
* str_cpy - A Function to copy a string.
* @dest: Pointer to newly made string.
* @src: Pointer to string being copied.
*
* Return: Number of characters.
*/
char *str_cpy(char *dest, char *src)
{
int i;
for (i = 0; src[i] != '\0'; i++)
dest[i] = src[i];
dest[i] = '\0';
return (dest);
}
/**
* str_cat - A Function to concatenate a string
* @dest: String to modify.
* @src: String to modify with.
*
* Return: Newly modified string.
*/
char *str_cat(char *dest, char *src)
{
int i, len1, len2;
len1 = str_len(dest);
len2 = str_len(src);
for (i = 0; i <= len2; i++)
{
dest[len1 + i] = src[i];
}
return (dest);
}