-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathstringsB.c
64 lines (52 loc) · 1003 Bytes
/
stringsB.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
58
59
60
61
62
63
64
#include "header.h"
/**
* _strcpy - copies a string from src to dest
* @dest: new copy of string
* @src: the source of the copy
*
* Return: pointer to copy
*/
char *_strcpy(char *dest, char *src)
{
int c;
for (c = 0; src[c] != '\0'; c++)
dest[c] = src[c];
dest[c] = '\0';
return (dest);
}
/**
* _strncpy - copies string from source to destination
* @dest: destination string
* @src: source string to be copied
* @n: bytes to be copied from source string
*
* Return: destination string concatenated
*/
char *_strncpy(char *dest, char *src, int n)
{
int j;
for (j = 0; j < n && src[j] != '\0'; j++)
dest[j] = src[j];
while (j < n)
{
dest[j] = '\0';
j++;
}
return (dest);
}
/**
* _strcat - concatenates from src string to dest string
* @dest: destination string
* @src: source string
*
* Return: pointer to destination
*/
char *_strcat(char *dest, char *src)
{
while (*dest)
dest++;
while (*src)
*(dest++) = *(src++);
*dest = '\0';
return (dest);
}