Char *strchr (const char *s, int c)
Function: Find the position of the first C character in the string s
Description: Returns a pointer to the position of the first occurrence of C, the returned address is the first pointer to the string that is searched for the same character as C, and returns null if there is no C in s ....
Return value: Successfully returns the position of the first occurrence of the character to be found, otherwise returns null ....
The following is the STRCHR () function that you implement:
Char *my_strchr (const char *s, int c)
{
if (s = = null)
{
return null;
}
while (*s! = ')
} {
if (*s = = (char) c)
{
return (char *) s;
}
s++;
}
return NULL;
}
Char *strrchr (const char *s, int c)
Function: Find a character C in the last occurrence of a string s (that is, starting from the right of S to find the first occurrence of the character C), and return all characters from the position where the character C in the string starts until the string s ends. If the character C is not found, NULL is returned.
The following is the function that you implement:
Char *strrchr (const char *s, int c)
{
if (s = = null)
{
return null;
}
char *p_char = NULL;
while (*s! = ')
} {
if (*s = = (char) c)
{
P_char = (char *) s;
}
s++;
}
return P_char;
}