maxishell
Implementation of a shell for Linux-like systems
Loading...
Searching...
No Matches
ft_strrchr.c File Reference
#include "libft.h"
Include dependency graph for ft_strrchr.c:

Go to the source code of this file.

Functions

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

Function Documentation

◆ ft_strrchr()

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

Definition at line 24 of file ft_strrchr.c.

25{
26 unsigned char uc;
27 const char *last_occurrence;
28
29 last_occurrence = NULL;
30 uc = (unsigned char)c;
31 while (*s != '\0')
32 {
33 if (*s == uc)
34 last_occurrence = s;
35 s++;
36 }
37 if (*s == uc)
38 return ((char *)s);
39 return ((char *)last_occurrence);
40}