查找字符串中要查找的字符串最后一次出现的位置

 C++ Code 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include <stdio.h>
#include <string.h>

//查找字符串中要查找的字符串最后一次出现的位置
char *strrstr ( const  char*string,  const  char*str)
{
     char *index =  NULL;
     char *ret =  NULL;
     int i =  0;
     do{
        index = strstr(string + i++, str);
         if (index !=  NULL)
            ret = index;
    } while(index !=  NULL);
     return ret;
}

int main()
{
     char str[] =  "abc123abc456abc789";
    printf( "%s\n", strrstr(str,  "abc"));
     return  0;
}

版权声明:本文为MULTISENSOR原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。