Libft
42 Libft library documentation
Loading...
Searching...
No Matches
ft_strchr.c File Reference
#include <stdlib.h>
+ Include dependency graph for ft_strchr.c:

Go to the source code of this file.

Functions

char * ft_strchr (const char *s, int c)
 Finds the first occurrence of a character in a string.
 

Function Documentation

◆ ft_strchr()

char * ft_strchr ( const char *  s,
int  c 
)

Finds the first occurrence of a character in a string.

The terminating '\0' is considered part of the string.

Parameters
sInput string.
cCharacter to search for.
Returns
Pointer to the first match, or NULL if not found.

Definition at line 24 of file ft_strchr.c.

25{
26 while (*s != (char)c)
27 {
28 if (!*s)
29 return (NULL);
30 s++;
31 }
32 return ((char *)s);
33}

Referenced by ft_strtrim().

+ Here is the caller graph for this function: