find last string
Definition
int find_last_string(char *string, char *search, size_t offset);
Description
Find the position of the last occurrence of the string to search
Parameters
- string
- String which should be searched in.
- search
- String which should be searched for.
- offset
- Offset, starting at the end, where to start the search.
Return Value
When search is found, the position is returned, else -1 is returned.
Example
#include <stdio.h> #include <libc/string.h> int main(int argc, char *argv[]) { char *original_string = create_string("Hello World Hello!"); int position = find_last_string(original_string, "Hello", 0); printf("pos: %i\n", position); free(original_string); return 0; }
Output:
pos: 12