I am trying to find a similar function to strstr
that searches a substring starting from the end towards the beginning of the string.
相关问题
- Sorting 3 numbers without branching [closed]
- Multiple sockets for clients to connect to
- How to compile C++ code in GDB?
- Why does const allow implicit conversion of refere
- how to split a list into a given number of sub-lis
You can use standard algorithm std::find_end for this purpose. For example
There isn't one in the standard C library. You may be able to find one on the web, or you may have to write your own.
Long story short:
Nope - there is no function in the C-library that does what you need..
But as others have pointed out: It's not rocket-science to write such a function...
Here is the most minimal simple implantation that I could come up with. Unlike other implementations of this function it avoids the initial strstr call that some other people like user3119703 had.
If you can use C++, you can search strings like this: