Difference Between str.find() in C++ and matching algorithms like KMP etc. and strstr() in C ?

What Is The Difference Between This STL Function and These KMP Algorithms…
and also function strstr() in c

1 Like

In general the answer will be: It depends on the implementation. For the gnu compiler you can look it up for yourself in the source code of gcc or glibc. I had a short look at the glibc version of strstr. They seem to use the naive algorithm for short strings and some kind of improved version of KMP for linger strings. So in essence if you’re just looking for a substring, there is no reason to implement something like KMP because the library version will be roughly as fast as yours.

3 Likes

Great stuff from you, Ive read your stuff before and you’re just too awesome. But I really enjoyed the article. [buy cheap essays][1]
[1]: http://www.essayvalley.co.uk/buy-essay/

Very interesting, I can ask about this, my friends. Moreover, I was really confused a little by it.But I can share with you a great topic, which helps me a lot. What do you do when you have no time left to complete or start your term paper? You can start your term paper here - termpapers.kinja.com/

//