Is there a reverse function for strstr

后端 未结 17 2330
闹比i
闹比i 2020-12-18 18:28

I am trying to find a similar function to strstr that searches a substring starting from the end towards the beginning of the string.

17条回答
  •  南方客
    南方客 (楼主)
    2020-12-18 19:09

    I think you can still do it using library functions.

    1.Use strrev function to reverse the string.

    2.Use strstr function to do whatever you want to do.

    3.You can find start index (from reverse ) of the search string by subtracting start index of the search string from the length of original string.

提交回复
热议问题