Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <time.h>
- #include <limits.h>
- #define ABS(n) n >= 0 ? n : -n
- int strrindex(char *s, char *t)
- {
- int r_index = -1;
- char *start = s;
- while(*s)
- {
- if (*s == *t)
- {
- int pos = 0;
- for(; *(s + pos) != '\0' && *(t + pos) != '\0'
- && *(s + pos) == *(t + pos);)
- pos++;
- if (*(t + pos) == '\0')
- r_index = s - start;
- }
- s++;
- }
- return r_index;
- }
- int main(void)
- {
- char *str = "qwe qwe rasrawdabc asdawd abcqwe";
- char *search = "qwe";
- printf("%i", strrindex(str, search));
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement