Skip to content

Commit 65c4460

Browse files
committed
Add 2
1 parent 780cdc2 commit 65c4460

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

pointers_arrays_strings/2-strchr.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#include "main.h"
2+
3+
/**
4+
* _strchr - Locates a character in a string.
5+
* @s: The string to be searched.
6+
* @c: The character to be located.
7+
*
8+
* Return: If c is found - a pointer to the first occurence.
9+
* If c is not found - NULL.
10+
*/
11+
char *_strchr(char *s, char c)
12+
{
13+
int i;
14+
15+
for (i = 0; s[i] >= '\0'; i++)
16+
{
17+
if (s[i] == c)
18+
return (s + i);
19+
}
20+
21+
return ('\0');
22+
}

0 commit comments

Comments
 (0)