Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- char *my_strrchr (char *str, int ch)
- {
- char *res = NULL;
- while (*str)
- if (ch == *str++)
- res = str - 1;
- if (*str == ch)
- res = str;
- return res;
- }
- char *my_strchr (char *str, int ch)
- {
- while (*str)
- if (ch == *str++)
- return --str;
- if (*str == ch)
- return str;
- return NULL;
- }
- size_t my_strcspn(char *str1, char *str2)
- {
- int i = 0;
- while (*str1)
- {
- char *ptr = str2;
- int res = 0;
- while (*ptr)
- res += (*str1 == *ptr++);
- if (res)
- return i;
- i++;
- str1++;
- }
- return i;
- }
- size_t my_strspn(char *str1, char *str2)
- {
- int i = 0;
- while (*str1)
- {
- char *ptr = str2;
- int res = 0;
- while (*ptr)
- res += (*str1 == *ptr++);
- if (!res)
- return i;
- i++;
- str1++;
- }
- return i;
- }
- char *my_strbrk(char *str1, char *str2)
- {
- while (*str1)
- {
- char *ptr = str2;
- while (*ptr)
- if(*str1 == *ptr++)
- return str1;
- str1++;
- }
- return NULL;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement