-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstrcat.c
More file actions
50 lines (42 loc) · 763 Bytes
/
Copy pathstrcat.c
File metadata and controls
50 lines (42 loc) · 763 Bytes
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 "main.h"
/**
* _strcat - concatenate two strings
* @dest: char string to concatenate to
* @src: char string
* Return: pointer to resulting string `dest`
*/
char *_strcat(char *dest, char *src)
{
int i, c;
for (i = 0; dest[i] != '\0'; i++)
;
for (c = 0; src[c] != '\0'; c++)
{
dest[i] = src[c];
i++;
}
dest[i] = '\0';
return (dest);
}
/**
* _strchr - locates a character in a string
*
* @s: the string to check
* @c: the character we're looking for
*
* Return: a pointer to the first occurance of the character @c in the string
* @s. Return NULL if the character isn't found
*/
char *_strchr(char *s, char c)
{
while (*s)
{
if (*s != c)
s++;
else
return (s);
}
if (c == '\0')
return (s);
return (NULL);
}